tsan: fix crash during thread exit
authorDmitry Vyukov <dvyukov@google.com>
Tue, 16 Nov 2021 13:29:02 +0000 (14:29 +0100)
committerDmitry Vyukov <dvyukov@google.com>
Tue, 16 Nov 2021 15:43:09 +0000 (16:43 +0100)
commitc7081b5b4cb57f27e6a075e1b5a63b7951cd8a7a
tree19c7d493f7d889a33c9903b3f74c58d24077aa09
parent50acc6d0f7dd120a1de589d241423fe5bdf54add
tsan: fix crash during thread exit

Use of gethostent provokes caching of some resources inside of libc.
They are freed in __libc_thread_freeres very late in thread lifetime,
after our ThreadFinish. __libc_thread_freeres calls free which
previously crashed in malloc hooks.
Fix it by setting ignore_interceptors for finished threads,
which in turn prevents malloc hooks.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113989
compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
compiler-rt/test/tsan/Linux/sethostent.cpp [new file with mode: 0644]