mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [patch] don't use SA_ONSTACK for SIGCANCEL
@ 2025-01-02 12:42 nick black
  0 siblings, 0 replies; only message in thread
From: nick black @ 2025-01-02 12:42 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 2037 bytes --]

this is not necessarily a bug in musl, but it's certainly close
imho. thanks for the great work on musl over the years!

my alternate stack is not a verdant field to be stomped upon by
wayward signals of the musl golden horde. i expect it to be
used for the signals i have registered with SA_ONSTACK.

there is an argument to be made that "The range of addresses
starting at ss_sp up to but not including ss_sp+ ss_size is
available to the implementation for use as the stack." makes the
alternate signal stack free game. i would be stunned, however,
if some named signal was handled on the alternate stack without
me having called SA_ONSTACK in conjunction with it (and this
would not happen with musl -- only SIGCANCEL acts thus).

this caused problems as noticed in
https://github.com/dankamongmen/notcurses/issues/2828

now, free()ing a stack i still have registered for my thread is
unorthodox, perhaps even questionable. definitely questionable.
if there's no benefit from the SA_ONSTACK here, though, i feel
it serves the Law of Least Astonishment to kill it.

commit 8c4a1758bfd432b677db0bae8e4a1a3482dec31d
Author: nick black <dankamongmen@gmail.com>
Date:   Thu Jan 2 07:32:10 2025 -0500

    [pthread_cancel] don't handle SIGCANCEL on altstack
    
    Don't use the receiving thread's alternate signal
    stack for SIGCANCEL; they gave us no permission
    to do so.
    
    Signed-off-by: nick black <dankamongmen@gmail.com>

diff --git src/thread/pthread_cancel.c src/thread/pthread_cancel.c
index 139a6fc8..8ea0b545 100644
--- src/thread/pthread_cancel.c
+++ src/thread/pthread_cancel.c
@@ -82,7 +82,7 @@ void __testcancel()
 static void init_cancellation()
 {
 	struct sigaction sa = {
-		.sa_flags = SA_SIGINFO | SA_RESTART | SA_ONSTACK,
+		.sa_flags = SA_SIGINFO | SA_RESTART,
 		.sa_sigaction = cancel_handler
 	};
 	memset(&sa.sa_mask, -1, _NSIG/8);

-- 
nick black -=- https://nick-black.com
to make an apple pie from scratch,
you need first invent a universe.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-01-02 13:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-02 12:42 [musl] [patch] don't use SA_ONSTACK for SIGCANCEL nick black

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).