Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3085,6 +3085,10 @@ void InitializeInterceptors() {
#if !SANITIZER_ANDROID
TSAN_INTERCEPT(dl_iterate_phdr);
#endif

// Symbolization indirectly calls dl_iterate_phdr
ready_to_symbolize = true;

TSAN_MAYBE_INTERCEPT_ON_EXIT;
TSAN_INTERCEPT(__cxa_atexit);
TSAN_INTERCEPT(_exit);
Expand Down
6 changes: 6 additions & 0 deletions compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,12 @@ void CheckUnwind() {

bool is_initialized;

// Symbolization indirectly calls dl_iterate_phdr. If a CHECK() fails early on
// (prior to the dl_iterate_phdr interceptor setup), resulting in an attempted
// symbolization, it will segfault.
// dl_iterate_phdr is not intercepted for Android.
bool ready_to_symbolize = SANITIZER_ANDROID;

void Initialize(ThreadState *thr) {
// Thread safe because done before all threads exist.
if (is_initialized)
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/tsan/rtl/tsan_rtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@

namespace __tsan {

extern bool ready_to_symbolize;

#if !SANITIZER_GO
struct MapUnmapCallback;
# if defined(__mips64) || defined(__aarch64__) || defined(__loongarch__) || \
Expand Down
11 changes: 10 additions & 1 deletion compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,16 @@ ALWAYS_INLINE USED void PrintCurrentStack(uptr pc, bool fast) {
ptrace->trace_buffer[i] = ptrace->trace_buffer[ptrace->size - i - 1];
ptrace->trace_buffer[ptrace->size - i - 1] = tmp;
}
PrintStack(SymbolizeStack(*ptrace));

if (ready_to_symbolize) {
PrintStack(SymbolizeStack(*ptrace));
} else {
Printf(
"WARNING: PrintCurrentStack() has been called too early, before "
"symbolization is possible. Printing unsymbolized stack trace:\n");
for (unsigned int i = 0; i < ptrace->size; i++)
Printf(" #%u: 0x%zx\n", i, ptrace->trace[i]);
}
#endif
}

Expand Down
Loading