pthread_cancel async-signal-safe
Adhemerval Zanella
adhemerval.zanella@linaro.org
Fri Dec 4 18:19:56 GMT 2020
POSIX states that pthread_cancel should be async-signal-safe [1].
IMU there are two main issues in current implementation that prevents
it:
1. The pthread_cancel_init for shared builds,
2. And the SIGCANCEL raise for asynchronous cancellation.
For 2. it would be possible to use a safer raise implementation and I
have sent a patch where it fixes for pthread_kill [2]. It should be
simple to use __pthread_kill_internal on pthread_cancel as well.
For 1. I don't see a easier solution without moving pthread_cancel_init
to out of pthread_cancel and this has its own drawbacks (by always
forcing loading libgcc_s.so when libpthread is linked).
Florian, I recall that you had investigate some issue regarding C++
exceptions and signal handler that you presented on previous GNU
Cauldron, so I wonder if you might have an idea how we can fix it.
Maybe linking libgcc_s.a statically with libpthread and remove the
dynamic loading of libgcc_s.so? I am not sure of this implication
of this strategy.
[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html
[2] https://sourceware.org/pipermail/libc-alpha/2020-December/120419.html
More information about the Libc-alpha
mailing list