testThreadSanitizer.cmake 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # this file simulates a program that has been built with ThreadSanitizer
  2. # options
  3. message("TSAN_OPTIONS = [$ENV{TSAN_OPTIONS}]")
  4. string(REGEX REPLACE ".*log_path=\'([^\']*)\'.*" "\\1" LOG_FILE "$ENV{TSAN_OPTIONS}")
  5. message("LOG_FILE=[${LOG_FILE}]")
  6. set(error_types
  7. "data race"
  8. "data race on vptr (ctor/dtor vs virtual call)"
  9. "heap-use-after-free"
  10. "thread leak"
  11. "destroy of a locked mutex"
  12. "double lock of a mutex"
  13. "unlock of an unlocked mutex (or by a wrong thread)"
  14. "read lock of a write locked mutex"
  15. "read unlock of a write locked mutex"
  16. "signal-unsafe call inside of a signal"
  17. "signal handler spoils errno"
  18. "lock-order-inversion (potential deadlock)"
  19. )
  20. # clear the log file
  21. file(REMOVE "${LOG_FILE}.2343")
  22. # create an error of each type of thread santizer
  23. # these names come from tsan_report.cc in llvm
  24. foreach(error_type ${error_types} )
  25. file(APPEND "${LOG_FILE}.2343"
  26. "==================
  27. WARNING: ThreadSanitizer: ${error_type} (pid=27978)
  28. Write of size 4 at 0x7fe017ce906c by thread T1:
  29. #0 Thread1 ??:0 (exe+0x000000000bb0)
  30. #1 <null> <null>:0 (libtsan.so.0+0x00000001b279)
  31. Previous write of size 4 at 0x7fe017ce906c by main thread:
  32. #0 main ??:0 (exe+0x000000000c3c)
  33. Thread T1 (tid=27979, running) created by main thread at:
  34. #0 <null> <null>:0 (libtsan.so.0+0x00000001ed7b)
  35. #1 main ??:0 (exe+0x000000000c2c)
  36. SUMMARY: ThreadSanitizer: ${error_type} ??:0 Thread1
  37. ==================
  38. ")
  39. endforeach()