diff options
author | Vitaly Buka <vitalybuka@google.com> | 2022-03-31 21:58:44 -0700 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2022-04-25 14:56:44 -0700 |
commit | 0c99575df4a9395e32bf1121c103616ba812accb (patch) | |
tree | 4b286027b40dfb3fe2df8b2913b3498337e2d12c /llvm/unittests/ADT/SmallVectorTest.cpp | |
parent | 09e75d3f0996d58cba7477d3d1f04b1e8e12c595 (diff) | |
download | llvm-0c99575df4a9395e32bf1121c103616ba812accb.zip llvm-0c99575df4a9395e32bf1121c103616ba812accb.tar.gz llvm-0c99575df4a9395e32bf1121c103616ba812accb.tar.bz2 |
[libc++] Avoid lifetime UB in __thread_local_data()
Detected on many lld tests with -fsanitize-memory-use-after-dtor.
Also https://lab.llvm.org/buildbot/#/builders/sanitizer-x86_64-linux-fast after D122869 will report a lot of them.
Threads may outlive static variables. Even if ~__thread_specific_ptr() does nothing, lifetime of members ends with ~ and accessing the value is UB https://eel.is/c++draft/basic.life#1
```
==9214==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x557e1cec4539 in __libcpp_tls_set ../include/c++/v1/__threading_support:428:12
#1 0x557e1cec4539 in set_pointer ../include/c++/v1/thread:196:5
#2 0x557e1cec4539 in void* std::__msan::__thread_proxy<
std::__msan::tuple<...>, llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()::operator()() const::'lambda'()> >(void*) ../include/c++/v1/thread:285:27
Memory was marked as uninitialized
#0 0x557e10a0759d in __sanitizer_dtor_callback compiler-rt/lib/msan/msan_interceptors.cpp:940:5
#1 0x557e1d8c478d in std::__msan::__thread_specific_ptr<std::__msan::__thread_struct>::~__thread_specific_ptr() libcxx/include/thread:188:1
#2 0x557e10a07dc0 in MSanCxaAtExitWrapper(void*) compiler-rt/lib/msan/msan_interceptors.cpp:1151:3
```
The test needs D123979 or -fsanitize-memory-param-retval enabled by default.
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D122864
Diffstat (limited to 'llvm/unittests/ADT/SmallVectorTest.cpp')
0 files changed, 0 insertions, 0 deletions