I finally worked out how to make abort() conforming when SIGABRT's disposition is under aggressive alteration by other threads, and it's gloriously simple. Especially if you've ever read the (utterly wrong) glibc monstrosity: https://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/abort.c;h=9bb97c10552223a65f2a423cb6d5ad184fad5438;hb=HEAD …
-
-
POSIX Rationale (http://pubs.opengroup.org/onlinepubs/9699919799/functions/abort.html …) clarifies that abort was not required to be AS-safe until C99, and before that POSIX bogusly required non-AS-safe behavior like flushing stdio FILEs...
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
What is supposed to happen if two threads run abort() concurrently? The interesting case would be if a signal handler is installed. It runs potentially twice concurrently? Is the program supposed to mask SIGABRT except in one thread?
-
abort is specified to behave as if it performs raise(SIGABRT), and not to perform any termination if SIGABRT is caught and the handler does not return. I read that as allowing well-defined concurrent calls as long as the handler does not return (each thread enters a handler)...
-
Once a handler returns (observable by raise returning in the abort implementation), though, it's mandated that program termination happen as if by SIGABRT, so there's really no concurrency issue at this point. Another thread calling abort is not sequenced wrt the sigreturn, so...
-
...it's possible that a concurrent abort from another thread may still have a small window to run, but this situation is not observably different from signal handler still being about to return in the first (or abort not yet entered, if first has SIGABRT blocked).
-
So I think we're in an agreement that a program handling SIGABRT, which may have multiple threads (perhaps through libraries), needs to synchronize in the signal handler if it can't safely be run concurrently/multiple times.
-
Yes, but normally a library making threads that are supposed to be transparent to the application needs to block all signals in those threads anyway, and of course not do things that would terminate the process, which is rather non-transparent. :-)
-
I need to write that libraries(7) manual page for Sortix that documents these best practices. I forgot what the that page was called on Linux.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.