ThreadSanitizer does not work with C11 threads
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
It looks like this has been a known issue since at least 2022, and was reported on https://github.com/google/sanitizers/issues/1603, but it looks like the issue wasn't moved here when ThreadSanitizer was.
```c
#include
#include
int thread_fn(void *arg) {
assert(!arg);
return 0;
}
int main(void) {
thrd_t thread;
int status = thrd_create(&thread, &thread_fn, NULL);
assert(status == thrd_success);
thrd_join(thread, NULL);
}
```
```sh
$ clang --version
clang version 22.1.5
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ clang -std=c11 -fsanitize=thread -g c11-tsan-test.c && ./a.out
ThreadSanitizer:DEADLYSIGNAL
==148462==ERROR: ThreadSanitizer: SEGV on unknown address 0x000000000018 (pc 0x555ec9a31873 bp 0x7fb4aa9fe6a0 sp 0x7fb4aa9fe688 T148464)
==148462==The signal is caused by a READ memory access.
==148462==Hint: address points to the zero page.
ThreadSanitizer:DEADLYSIGNAL
ThreadSanitizer: nested bug in the same thread, aborting.
```
Also relevant: https://groups.google.com/g/thread-sanitizer/c/0xA7qH2Pr-o
Contributor guide
Assessment
This issue has not been assessed yet.