NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/58562: libedit should register signal handlers with SA_ONSTACK flag



>Number:         58562
>Category:       lib
>Synopsis:       libedit should register signal handlers with SA_ONSTACK flag
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 08 17:55:00 +0000 2024
>Originator:     Thomas Koeppe
>Release:        head (75a90611a8098945540ed10d5831622fadcde4ae)
>Organization:
Google
>Environment:
Linux/Debian
>Description:
The signal handlers registered in lib/libedit/sig.c currently use the regular stack. I propose to set the SA_ONSTACK flag to allow the handler to use the alternate signal stack if one is available in the handling thread, but if there isn't, there is no effect.

This change would respect existing choices better. Specifically, this allows signal handlers to be set when the process includes a Go runtime, since Go enforces that all signal handlers in the process use the SA_ONSTACK flag (e.g. see https://github.com/golang/go/issues/20400).
>How-To-Repeat:
Include libedit in some binary that is running a Go runtime and install the signal handlers. This causes the Go runtime to abort with this error:

```
Handler for signal 28 registered without SA_ONSTACK: {Handler: <sig_handler>, Flags: [0x4000000]}                                                                                                                                                                                                                                                                           
Go-incompatible signal handlers found; aborting.
```
>Fix:
See https://github.com/NetBSD/src/pull/40:

--- old/src/sig.c
+++ new/src/sig.c
@@ -167,7 +167,7 @@
 	struct sigaction osa, nsa;
 
 	nsa.sa_handler = sig_handler;
-	nsa.sa_flags = 0;
+	nsa.sa_flags = SA_ONSTACK;
 	sigemptyset(&nsa.sa_mask);
 
 	(void) sigprocmask(SIG_BLOCK, &el->el_signal->sig_set, &oset);



Home | Main Index | Thread Index | Old Index