I have an implementation of a lockfree queue, which I believe to be correct (or at least data race-free):
#include
#include
#include
#include
struct Job {
int id;
int data;
};
class JobQueue {
using…
I've always thought that using std::cout << something was thread safe.
For this little example
#include
#include
void f()
{
std::cout << "Hello from f\n";
}
void g()
{
std::cout << "Hello from g\n";
}
int main()
{
…
I'm trying to use the Thread Sanitizer in Xcode 11.2.1 but whenever the app launches (just a single view app from Xcode's template, nothing added) it hits __abort_with_payload:
libsystem_kernel.dylib`__abort_with_payload:
0x7fff51b73be0 <+0>: …
I'm working on cleaning up ThreadSanitizer warnings in a largeish project. In particular in this exact case, there is a spawned thread which reads from a file, producer. Then there are one or more decompression threads as part of a thread pool.…
Please have a look at the following code:
#include
#include
class ReferenceCounted {
public:
ReferenceCounted() : ref_count_(1) {}
void reserve() {
ref_count_.fetch_add(1,…
I am trying to use --thread-sanitizer option of clang on OSX:
$ clang++ -fthread-sanitizer -fpic tsan1.cc
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.3.0
Thread model: posix
[...]
clang -cc1 version…
I am debugging A segfault reported by TSAN in the CI of Boost.Beast.
I strongly believe it to be a false positive, but I don't know what to look for in order to suppress it.
It seems to me from the stack trace that the code is correctly…
I learned that TSAN doesn't understand std::atomic_thread_fence, and to fix it, you need to tell TSAN which atomic variables are affected by the fence, by putting __tsan_acquire(void *) and __tsan_release(void *) next to it (for acquire and release…
I compile using Clang with -g3 and -O1 flags, but TSan complains that it found a data-race and it outputs a totally obscure stack trace with no clear line numbers.
How to find line numbers in this case?
Output on Pastebin since Stack Overflow…
There is a similar question for address sanitizers, but for thread sanitizers, it doesn't work, I have tried to break on __sanitizer_print_stack_trace, which doesn't work either.
I have code which is identified by tsan as lock-order-inversion. It is a false positive. I know I can use suppression files to prevent this but I wonder whether I can do something with my code so that my intention is clearer and it doesn't get…
How can I detect whether thread sanitizer has been turned on for a build using gcc 5? Neither one of the two between __has_feature(thread_sanitizer) nor __SANITIZE_THREAD__ work
#include
using std::cout;
using std::endl;
int main() {
…
I am trying to hunt down some deadlock in multi-threaded code which uses a condition variable. Somebody advised using thread sanitizer. So I compiled LLVM from source and enabled thread sanitizer
LLVM built fine, but when I try to build my project…
To experiment with the thread-sanitizer, I created a tiny C++ program which by purpose contains a data race. Indeed, tsan does detect the error, great! However I am puzzled by the generated message...
It reports a write-write data race, where I…
Here is a simple example for using std::condition_variable. When using clang+tsan for building the following code,
#include
#include
#include
#include
#include
#include
class…