Skip to content

Commit 789bfdc

Browse files
authored
[OMPT] Use __tsan_init to detect TSan binaries rather than RunningOnValgrind (#128357)
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 65cf534 commit 789bfdc

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

openmp/tools/archer/ompt-tsan.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ DECLARE_TSAN_FUNCTION(AnnotateNewMemory, const char *, int,
166166
const volatile void *, size_t)
167167
DECLARE_TSAN_FUNCTION(__tsan_func_entry, const void *)
168168
DECLARE_TSAN_FUNCTION(__tsan_func_exit)
169-
170-
// RunningOnValgrind is used to detect absence of TSan and must intentionally be a nullptr.
171-
static int (*RunningOnValgrind)(void);
172169
}
173170

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

12531250
// The OMPT start-up code uses dlopen with RTLD_LAZY. Therefore, we cannot
12541251
// 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
1252+
// for the first TSan call. We use __tsan_init to detect whether
12561253
// an implementation of the Annotation interface is available in the
12571254
// execution or disable the tool (by returning NULL).
12581255

1259-
findTsanFunctionSilent(RunningOnValgrind, (int (*)(void)));
1260-
if (!RunningOnValgrind) // if we are not running on TSAN, give a different
1261-
// tool the chance to be loaded
1256+
void (*__tsan_init)(void) = nullptr;
1257+
1258+
findTsanFunctionSilent(__tsan_init, (void (*)(void)));
1259+
if (!__tsan_init) // if we are not running on TSAN, give a different
1260+
// tool the chance to be loaded
12621261
{
12631262
if (archer_flags->verbose)
12641263
std::cout << "Archer detected OpenMP application without TSan; "

0 commit comments

Comments
 (0)