[PATCH] Fix PR/21658: gdbserver doesn't start on some libcs

André Draszik git@andred.net
Fri Jun 23 08:18:00 GMT 2017


From: André Draszik <adraszik@tycoint.com>

gdbserver currently fails to start on musl-libc based systems
with 'sigprocmask: Invalid argument'

The reason is because it uses an invalid argument to sigprocmask():

  http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html

  The argument how indicates the way in which the set is changed, and
  the application shall ensure it consists of one of the following
  values
    SIG_BLOCK
    SIG_SETMASK
    SIG_UNBLOCK

  ...

  The pthread_sigmask() and sigprocmask() functions shall fail if:

  [EINVAL]
    The value of the how argument is not equal to one of
    the defined values.

This is what musl-libc implements, hence gdbserver fails to start.

Fix the call to use correct arguments.

gdb/ChangeLog:
2017-06-23  André Draszik  <adraszik@tycoint.com>

	PR gdb/21658
	* common/signals-state-save-restore.c
	(save_original_signals_state): Use POSIX-compliant arguments
	to sigprocmask().
---
 gdb/ChangeLog                           | 7 +++++++
 gdb/common/signals-state-save-restore.c | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 95010fc612..ac298bc074 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2017-06-23  André Draszik  <adraszik@tycoint.com>
+
+	PR gdb/21658
+	* common/signals-state-save-restore.c
+	(save_original_signals_state): Use POSIX-compliant arguments
+	to sigprocmask().
+
 2017-06-22  Sergio Durigan Junior  <sergiodj@redhat.com>
 
 	* common/environ.c (gdb_environ::unset): Update comment.
diff --git a/gdb/common/signals-state-save-restore.c b/gdb/common/signals-state-save-restore.c
index d11a9ae006..734335c3a2 100644
--- a/gdb/common/signals-state-save-restore.c
+++ b/gdb/common/signals-state-save-restore.c
@@ -41,7 +41,7 @@ save_original_signals_state (void)
   int i;
   int res;
 
-  res = sigprocmask (0,  NULL, &original_signal_mask);
+  res = sigprocmask (SIG_BLOCK,  NULL, &original_signal_mask);
   if (res == -1)
     perror_with_name (("sigprocmask"));
 
-- 
2.11.0



More information about the Gdb-patches mailing list