Dmitry Vyukov 3056ccdbae tsan: fix deadlock/crash in signal handling
We set in_blocking_func around some blocking C functions so that we don't
delay signal infinitely (if in_blocking_func is set we deliver signals
synchronously).

However, pthread_join is blocking but also call munmap/free to free thread
resources. If we are inside the munmap/free interceptors called from
pthread_join and deliver a signal synchronously, it can lead to deadlocks
and crashes since we re-enter runtime and try to lock the same mutexes
or use the same per-thread data structures.

If we re-enter runtime via an interceptor when in_blocking_func is set,
temporary reset in_blocking_func around the interceptor and restore it back
when we return from the recursive interceptor.

Also move in_blocking_func from ThreadSignalContext to ThreadContext
so that we can CHECK that it's not set in SlotLocker ctor.

Fixes https://github.com/google/sanitizers/issues/1540

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D127845
2022-09-30 14:23:46 +02:00
..
2022-07-19 15:42:57 +02:00
2021-12-13 12:48:34 +01:00
2021-07-28 20:11:59 +02:00
2019-09-11 23:19:48 +00:00
2021-04-29 07:42:18 +02:00
2021-12-13 12:48:34 +01:00
2021-10-25 14:51:24 +02:00
2021-04-29 07:42:18 +02:00
2019-09-11 21:33:06 +00:00
2021-07-28 17:35:02 +02:00
2021-07-28 17:35:02 +02:00
2021-07-28 17:35:02 +02:00
2021-07-15 12:18:48 +02:00
2021-07-15 12:18:48 +02:00
2021-02-17 19:03:17 +01:00
2021-06-24 09:47:44 +02:00
2021-12-13 12:48:34 +01:00
2021-07-28 17:35:02 +02:00
2021-04-29 07:42:18 +02:00
2022-02-23 13:35:22 -08:00