summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/ctest_memcheck/testThreadSanitizer.cmake
blob: d59193146981e551858b4eaeffd259554f0d97a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# this file simulates a program that has been built with thread sanitizer
# options

message("TSAN_OPTIONS = [$ENV{TSAN_OPTIONS}]")
string(REGEX REPLACE ".*log_path=\"([^\"]*)\".*" "\\1" LOG_FILE "$ENV{TSAN_OPTIONS}")
message("LOG_FILE=[${LOG_FILE}]")

set(error_types
 "data race"
 "data race on vptr (ctor/dtor vs virtual call)"
 "heap-use-after-free"
 "thread leak"
 "destroy of a locked mutex"
  "double lock of a mutex"
  "unlock of an unlocked mutex (or by a wrong thread)"
  "read lock of a write locked mutex"
  "read unlock of a write locked mutex"
  "signal-unsafe call inside of a signal"
  "signal handler spoils errno"
  "lock-order-inversion (potential deadlock)"
 )

# clear the log file
file(REMOVE "${LOG_FILE}.2343")

# create an error of each type of thread santizer
# these names come from tsan_report.cc in llvm
foreach(error_type ${error_types} )

  file(APPEND "${LOG_FILE}.2343"
"==================
WARNING: ThreadSanitizer: ${error_type} (pid=27978)
  Write of size 4 at 0x7fe017ce906c by thread T1:
    #0 Thread1 ??:0 (exe+0x000000000bb0)
    #1 <null> <null>:0 (libtsan.so.0+0x00000001b279)

  Previous write of size 4 at 0x7fe017ce906c by main thread:
    #0 main ??:0 (exe+0x000000000c3c)

  Thread T1 (tid=27979, running) created by main thread at:
    #0 <null> <null>:0 (libtsan.so.0+0x00000001ed7b)
    #1 main ??:0 (exe+0x000000000c2c)

SUMMARY: ThreadSanitizer: ${error_type} ??:0 Thread1
==================
")
endforeach()