Skip to content

Commit 743c980

Browse files
committed
[OMPT] Use a __tsan function to detect TSan binaries rather than RunningOnValgrind
Switch to using __tsan_init rather than RunningOnValgrind as the means for detecting TSan instumented binaries. RunningOnValgrind is present in other libraries (such as Google perftools tcmalloc). An exe that links with a tcmalloc static library and exports symbols with -rdynamic will appear to be TSan instrumented even when it is not resulting in "Unable to fint TSan function ..." messages. Fixes issue #122319.
1 parent 86ef031 commit 743c980

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

openmp/tools/archer/ompt-tsan.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ DECLARE_TSAN_FUNCTION(AnnotateNewMemory, const char *, int,
167167
DECLARE_TSAN_FUNCTION(__tsan_func_entry, const void *)
168168
DECLARE_TSAN_FUNCTION(__tsan_func_exit)
169169

170-
// RunningOnValgrind is used to detect absence of TSan and must intentionally be a nullptr.
171-
static int (*RunningOnValgrind)(void);
170+
// __tsan_init is used to detect absence of TSan and must intentionally be a nullptr.
171+
static void (*__tsan_init)(void);
172172
}
173173

174174
// This marker is used to define a happens-before arc. The race detector will
@@ -1252,12 +1252,12 @@ ompt_start_tool(unsigned int omp_version, const char *runtime_version) {
12521252

12531253
// The OMPT start-up code uses dlopen with RTLD_LAZY. Therefore, we cannot
12541254
// rely on dlopen to fail if TSan is missing, but would get a runtime error
1255-
// for the first TSan call. We use RunningOnValgrind to detect whether
1255+
// for the first TSan call. We use __tsan_init to detect whether
12561256
// an implementation of the Annotation interface is available in the
12571257
// execution or disable the tool (by returning NULL).
12581258

1259-
findTsanFunctionSilent(RunningOnValgrind, (int (*)(void)));
1260-
if (!RunningOnValgrind) // if we are not running on TSAN, give a different
1259+
findTsanFunctionSilent(__tsan_init, (void (*)(void)));
1260+
if (!__tsan_init) // if we are not running on TSAN, give a different
12611261
// tool the chance to be loaded
12621262
{
12631263
if (archer_flags->verbose)

0 commit comments

Comments
 (0)