Fix PR/21658: gdbserver doesn't start on some libcs
Commit Message
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(-)
Comments
On 06/23/2017 09:18 AM, André Draszik wrote:
> 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():
No it doesn't. This has come up before:
https://sourceware.org/ml/gdb-patches/2017-03/msg00426.html
which led to:
http://austingroupbugs.net/view.php?id=1132
> This is what musl-libc implements, hence gdbserver fails to start.
Please fix musl...
Thanks,
Pedro Alves
@@ -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.
@@ -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"));