[all-commits] [llvm/llvm-project] 97b4e6: tsan: fix false positives in dynamic libs with sta...
Dmitry Vyukov via All-commits
all-commits at lists.llvm.org
Thu Dec 2 08:47:18 PST 2021
Author: Dmitry Vyukov <dvyukov at google.com>
Date: 2021-12-02 (Thu, 02 Dec 2021)
tsan: fix false positives in dynamic libs with static tls
The added test demonstrates loading a dynamic library with static TLS.
Such static TLS is a hack that allows a dynamic library to have faster TLS,
but it can be loaded only iff all threads happened to allocate some excess
of static TLS space for whatever reason. If it's not the case loading fails with:
dlopen: cannot load any more object with static TLS
We used to produce a false positive because dlopen will write into TLS
of all existing threads to initialize/zero TLS region for the loaded library.
And this appears to be racing with initialization of TLS in the thread
since we model a write into the whole static TLS region (we don't what part
of it is currently unused):
WARNING: ThreadSanitizer: data race (pid=2317365)
Write of size 1 at 0x7f1fa9bfcdd7 by main thread:
[[ this is where main calls dlopen ]]
Previous write of size 8 at 0x7f1fa9bfcdd0 by thread T1:
Fix this by ignoring accesses during dlopen.
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D114953
More information about the All-commits