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
0
votes
0 answers

CLANG TSAN different result on multiple run same program

I have tried example from CLANG TSAN documentation (https://clang.llvm.org/docs/ThreadSanitizer.html): #include int Global; void *Thread1(void *x) { Global = 42; return x; } int main() { pthread_t t; pthread_create(&t, NULL,…
0
votes
1 answer

Global object registry in C++

I have multiple global object (say, Duck, Dog, Cat) which has to be global object, and they have a common parent class Animal. I try to use registry pattern in such way: declare all of these instances in global object in .cc file, like Cat…
Tinyden
  • 524
  • 4
  • 13
0
votes
0 answers

How does code know that it is compiled or running with AddressSanitizer or ThreadSanitizer?

I would like for my C++ program to be able to print if it was compiled with AddressSanitizer or ThreadSanitizer. The solution proposed in AddressSanitizer: How could we know that object file/executable in C is compiled with AddressSanitizer? will…
vy32
  • 28,461
  • 37
  • 122
  • 246
0
votes
1 answer

Disable thread leak test in ThreadSanitizer?

I'm using ThreadSanitizer with Catch2. Unfortunately, ThreadSanitizer is finding thread leaks with Catch2 and Thread race conditions in my code. Is there any way to disable ThreadSanitizer's thread leak detection but leaving on its race condition…
vy32
  • 28,461
  • 37
  • 122
  • 246
0
votes
1 answer

ThreadSanitaizer does not detect lock_cmpxchg and warn about data race

the following code acquire a mutex using lock_cmpxchg on an index of an array, then two threads write and read to the same index, but still thread sanitizer say there is a data race. how can I tell him the fact there is a lock between the threads…
Moshe Levy
  • 174
  • 9
0
votes
1 answer

How should I use DataRaceBench 1.3.2?

I am trying to install and to learn how to use DataRaceBench 1.3.2 which is a benchmark suite designed to systematically and quantitatively evaluate the effectiveness of data race detection tools as shown here enter link description here. I have a…
hakim
  • 139
  • 15
0
votes
1 answer

Why is ThreadSanitizer (TSAN) reporting data race on Glib::signal_idle().connect_once

Contents of hello.cpp #include void RunInMain() { printf("RunInMain\n"); } void ThreadFunc() { printf("ThreadFunc\n"); Glib::signal_idle().connect_once(std::bind(&RunInMain)); } int main() { Gtk::Main kit(0, NULL); …
Vern
  • 3
  • 2
0
votes
1 answer

What is a good way to apply multiple sanitizers in cmake with gcc

GCC has many sanitizers (e.g., leak, address, thread). But many of them require instumentation of the code and cannot be used together with others. So if in practice I want to apply all the sanitizers to make sure my code works well, what is a…
Harper
  • 1,794
  • 14
  • 31
0
votes
0 answers

Use ThreadSanitizer's Mutex names in code

I'm using GCC 9.2 TSan to analyze my codebase's runtime multithreading behavior (using pthreads explicitly -- we started before C++11). I have a data race while a destroyed mutex is held, with the following (relatively unhelpful): Mutex…
Irfy
  • 9,323
  • 1
  • 45
  • 67
0
votes
1 answer

ThreadSanitizer deadlock not detected and no result at the end (du to the deadlocked program)

I would like to know where is a deadlock with the thread sanitizer (clang) but the problem is that the program is blocked and the deadlock is not detected during the compilation with -fsanitize=thread option. And there no result at the end of the…
John Smith
  • 45
  • 3
0
votes
1 answer

Race condition in OpenMP outside parallel block (ThreadSanitizer); false positive?

The following minimal example computes the sum of all the numbers from 1 to 1000 and is parallelized with OpenMP: #include double sum; void do_it() { const size_t n = 1000; #pragma omp parallel { #pragma omp for for (size_t i =…
0
votes
1 answer

Thread sanitizer gives false negative for "function race"

Consider the following code: #include #include #include std::atomic x, y; std::atomic r1, r2; void f() { r1 = y.load(); x = r1.load(); } void g() { r2 = x.load(); y = 42; } int main() { x = 0; y…
R_Kapp
  • 2,818
  • 1
  • 18
  • 32
0
votes
1 answer

XPC Process Crashes in older macOS due to lack of Sanitizers

When I take a Debug Build of my macOS app, built in Xcode 9.1, and move it to a Mac running macOS 10.11 or 10.12 for testing, I find that my app's XPC process crashes on load, and the crash report indicates the cause is that the system cannot find…
0
votes
1 answer

C++ shared_ptr and threadsanitazer reporting data race

this is a paste from threadsanitazer (clang) which reports data race http://pastebin.com/93Gw7uPi Googling around it seems this is a problem with threadsanitazer (for example http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57507) So lets say this looks…
Petar
  • 1,034
  • 1
  • 12
  • 18
-1
votes
1 answer

Thread Sanitiser causing Crash on App launch

To check the existence of any threading issue I tried using Thread Sanitiser. But upon enabling it in Edit Scheme my app is crashing as soon as I launch the app. Below is the stack backtrace. * thread #1, stop reason = signal SIGABRT * frame #0:…
Amit Gupta
  • 192
  • 2
  • 13