Closed mrcnski closed 1 year ago
Hello
I'd say that most probably no, it is not. For several reasons:
pthread_cleanup_push
and it calls destructors for any relevant thread-local resources. While, in theory, one could ensure that all that stuff is signal safe, it would be really hard to do in practice since any library linked into the process may set up its own thread-local resources (quite common in Rust) and may use the cleanup functions (AFAIK rather rare). Both of these might use dynamic memory internally, to manipulate the lists of these things.But looking at the documentation of when a thread might get a SIGSYS, I think one possible solution would be to either ignore the signal and let the syscall fail for the process (and then hope error handling is correct and the thread gracefully reaches some sane error state / return value) or block the signal for the thread and pick it up later with something like sigwait.
And you're right, signal-hook isn't really the tool for this particular job.
Thanks for the informative answer! Quite interesting, though I appreciate your work in shielding Rust developers from these details.
In our case, we determined that instead of using the SECCOMP_RET_TRAP
action, having seccomp
kill the process is acceptable, if somewhat suboptimal. Cheers!
Hello. Thank you for the delightful blog posts about signals -- that was a fun rabbithole.
I have what is (hopefully) a simple question: is it safe to call
pthread_exit
inregister
?For background, I'm trying to handle a "thread-directed" signal (
SIGSYS
fromseccomp
) in a thread that does blocking work, and therefore can't usesignal-hook
's abstractions (AFAIK). I'm hoping to return a value from the single thread rather than just terminate the process.