I've boiled this down to a simple self-contained example. The main thread enqueues 1000 items, and a worker thread tries to dequeue concurrently. ThreadSanitizer complains that there's a race between the read and the write of one of the elements,…
I'm learning about different memory orders.
I have this code, which works and passes GCC's and Clang's thread sanitizers:
#include
#include
#include
int state = 0;
std::atomic_int a = 0;
void foo(int from, int to)…
Both clang++ and g++ sanitizers produce similar warning about data race for this simple code. Is it a false alarm? What is the problem?
Code:
#include
struct A
{
void operator()()
{
}
};
struct B
{
void operator()()
{
…
Xcode 8 incorporates the Thread Sanitizer, a tool for detecting race conditions and other threading-related issues.
I'm trying to run this against a project of mine, and am detecting many issues with a third-party binary library. These issues are…
Consider the following example:
#include
int main () {
int i = 0;
#pragma omp parallel
{
#pragma omp critical
{
++i;
}
}
std::cout << i;
}
Compiling with g++ -fopenmp…
I am experimenting with g++ and thread sanitizer and I think I am getting false positives. Is this true, or am I making some big mistake?
Program (cut&paste from Anthony Williams: C++ Concurrency in Action, page 145, listing 5.13)
#include…
gcc v4.8.x add options for debugging your program:
-fsanitize=thread
Enable ThreadSanitizer, a fast data race detector. Memory access instructions will be instrumented to detect data race bugs. See…
Has anyone tried clang's ThreadSanitizer with Intel Threading Building Blocks (TBB)?
My experience so far was that you will get a lot of warnings, even for relatively simple examples. Unfortunately, many of them seem to be false positives.
In this…
I'm running the MPMC example given in boost lockfree queue documentation with thread sanitizer and to my surprise this basic example contains data races as per TSan. Any idea what might be wrong?
OS: Red Hat Enterprise Linux Server release 7.7 /…
The below code produce a warning when running with thread sanitizer on macOS. I can't see where the race is. The control block of shared_ptr and weak_ptr is thread safe, and pushing and popping from the std::queue is done with a lock held.
#include…
I'm using a lock free stack (via tagged pointers) to manage a pool of small blocks of memory. The list nodes are created and destroyed in-place when the blocks are inserted into, and removed from, the pool.
This is a very simplified test program,…
When using sanitizers with gcc one can provide a list of exceptions/suppressions to deal with false positives and such.
the suppression file format is poorly documented.
Each suppression is of the form
name_of_check:path_or_name
What are the valid…
In Xcode 10.2 I can no longer run my app on a simulator with thread sanitizer enabled. I get the error
This app could not be installed at this time.
WatchKit v3 app has disallowed Info.plist key: NSBuiltWithThreadSanitizer
My app includes a watch…
According to the thread-sanitizer docs:
ThreadSanitizer uses more real memory than a native run. At the default settings the memory overhead is 5x plus 1Mb per each thread. Settings with 3x (less accurate analysis) and 9x (more accurate analysis)…
context: I am using thread sanitizer for my program, and it shows my program has data race. I'm 100% sure why (maybe there's too much memory access), thread sanitizer doesn't give out the exact stacktrace for the invalid access. There's…