Questions tagged [thread-sanitizer]

ThreadSanitizer (TSan) is a data race detector for C/C++ programs.

ThreadSanitizer (aka tsan, not "Thread Sanitizer") is a data race detector for C/C++ programs.

See also:

91 questions
3
votes
1 answer

Is it okay for std::future to outlive a std::promise?

The clang ThreadSanitizer reports a data race in the following code: #include #include #include int main() { std::cout << "start!" << std::endl; for (size_t i = 0; i < 100000; i++) { std::promise
jtbandes
  • 115,675
  • 35
  • 233
  • 266
3
votes
1 answer

Data race reported by ThreadSanitizer

I am using Clang-8 with thread sanitizer enabled to compile the code below std::atomic ptr {nullptr}; int data {0}; void producer() { std::string* p = new std::string("Hello"); data = 42; ptr.store(p,…
Tes
  • 349
  • 3
  • 12
3
votes
2 answers

How to avoid data race with GCD DispatchWorkItem.notify?

With Swift 3.1 on XCode 8.3, running the following code with the Thread Sanitizer finds a data race (see the write and read comments in the code): private func incrementAsync() { let item = DispatchWorkItem { [weak self] in guard let…
mna
  • 22,989
  • 6
  • 46
  • 49
3
votes
0 answers

Thread sanitizer reports data race when using std::packaged_task/std::exception_ptr

I am experiencing some issues with thread sanitizer (TSan) complaining about a data race in some production code where std::packaged_task are handed over to a dispatcher thread by wrapping them in a std::function. For this question I have simplified…
CHOP
  • 31
  • 2
3
votes
1 answer

ThreadSanitizer (tsan) - Suppression files vs blacklist files

Is there a difference between ThreadSanitizer suppression files and blacklist files? -- when used by the llvm-specific compiler flag of -fsanitize-blacklist= When should I use one over the other?
user1902689
  • 1,655
  • 2
  • 22
  • 33
2
votes
0 answers

Prevent false positives for thread sanitizer in extended lambda implementation

Note: Crossposted I am trying to use gcc's thread sanitizer (-fsanitize=thread) to check for data races in my application. Unfortunately, the output is flooded with what I think are false positives caused by the implementation of the extended…
Lukas Lang
  • 400
  • 2
  • 11
2
votes
0 answers

Does Tsan instrument inline assembly?

I have some code in my project in inline assembly, does TSAN instrument it? let's look at this example: T0: x++ T1: (inline assembly code) MOV x, 2; will we get data race here(assuming no sync at all)? if so, does it instrument all assembly memory…
Moshe Levy
  • 174
  • 9
2
votes
1 answer

data race with std::shared_timed_mutex::try_lock_until

I'm trying to write a small testcase to exercise std::shared_timed_mutex::try_lock_until. Documentation on cppreference. Here is my code #include #include #include #include #include
Paul Floyd
  • 5,530
  • 5
  • 29
  • 43
2
votes
1 answer

Thread Sanitizer - How to interpret the Read vs Previous Write warning

I am running a program with thread sanitizers and wonder how to interpret the following warning: ================== WARNING: ThreadSanitizer: data race (pid=2788668) Read of size 4 at 0x7f7eefc4e298 by main thread: [Stacktrace follows...] …
fabian
  • 1,413
  • 1
  • 13
  • 24
2
votes
3 answers

Swift access race with os_unfair_lock_lock

I made a custom property wrapper which provides a method to access data in a mutually exclusive context using an os_unfair_lock. After testing my wrapper with TSAN enabled, an access race error was reported at the point of lock acquisition using…
2
votes
0 answers

Can gdb set a breakpoint on a tsan-detected race condition?

I am testing some code using Google's tsan thread sanitizer. Tsan is telling me that I have a race condition in a particular function, but it is not clear to me from looking at the output what the problem is. Is it possible to set a breakpoint in…
Steven Scott
  • 481
  • 3
  • 14
2
votes
1 answer

TSAN build for QEMU, can't find longjmp buf

building QEMU with TSAN did not get any problem but it get FATAL during start up ThreadSanitizer: can't find longjmp buf FATAL: ThreadSanitizer CHECK failed: ../../../../src/libsanitizer/tsan/tsan_interceptors.cc:544 "((0)) != (0)" (0x0, 0x0) #0…
wmliang
  • 21
  • 2
2
votes
0 answers

Thread sanitizer reporting with QCoreApplication::postEvent() when calling into received event instance

I have following code: std::thread thread; EventReceiver target; { thread = std::thread([&]() { auto event = new MyEvent(); QCoreApplication::postEvent(&target, event); } }); IdleProcessor::processEvents(); …
Ghita
  • 4,465
  • 4
  • 42
  • 69
2
votes
1 answer

Turning on Thread Sanitizer results in signal SIGABRT

When I create a new Single View App from in Xcode Version 11.3 (11C29) and run it all is ok. When I turn on Thread Sanitize And try to run the very same app, I get Thread 1: signal SIGABRT this is the backtrace (lldb) bt * thread #1, stop reason…
byaruhaf
  • 4,128
  • 2
  • 32
  • 50
2
votes
0 answers

(Xcode 11.2.1) Cannot find Thread Sanitizer runtime support library (iOS)

With Xcode 11.2.1 created a single View project for iOS and enabled the Thread Sanitizer in Scheme. Note: Running the app on Simulator iPhone Xr 13.2.2 Once run the project, getting below error: The request was denied by service delegate…