Search code examples
cpthreadsclangdeadlockthread-sanitizer

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 execution cuz the program is blocked (impossible to quit the program due to the deadlock).


Solution

  • If the program is already blocked you don't need ThreadSanitizer to debug it. You can attach to a deadlocked process with gdb and see all threads stacktraces with thread apply all bt. You should see attempts to lock the same mutex from different threads in thread apply all bt output.