diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h index d0b0f827200e9..7fb7928dce0d8 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h @@ -187,7 +187,7 @@ class Symbolizer final { // If stale, need to reload the modules before looking up addresses. bool modules_fresh_; - // Platform-specific default demangler, must not return nullptr. + // Platform-specific default demangler, returns nullptr on failure. const char *PlatformDemangle(const char *name); static Symbolizer *symbolizer_; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp index a9c958b2d1001..f1cc0b5e1e8ac 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cpp @@ -42,7 +42,8 @@ bool DlAddrSymbolizer::SymbolizePC(uptr addr, SymbolizedStack *stack) { } const char *demangled = DemangleSwiftAndCXX(info.dli_sname); - if (!demangled) return false; + if (!demangled) + demangled = info.dli_sname; stack->info.function = internal_strdup(demangled); return true; } @@ -52,6 +53,8 @@ bool DlAddrSymbolizer::SymbolizeData(uptr addr, DataInfo *datainfo) { int result = dladdr((const void *)addr, &info); if (!result) return false; const char *demangled = DemangleSwiftAndCXX(info.dli_sname); + if (!demangled) + demangled = info.dli_sname; datainfo->name = internal_strdup(demangled); datainfo->start = (uptr)info.dli_saddr; return true; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp index 1a5e38faea887..1317facec1704 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp @@ -56,7 +56,7 @@ const char *DemangleCXXABI(const char *name) { __cxxabiv1::__cxa_demangle(name, 0, 0, 0)) return demangled_name; - return name; + return nullptr; } // As of now, there are no headers for the Swift runtime. Once they are diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp index ae2d3be19ef38..56cde2dcef1e0 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp @@ -175,9 +175,7 @@ const char *WinSymbolizerTool::Demangle(const char *name) { return name; } -const char *Symbolizer::PlatformDemangle(const char *name) { - return name; -} +const char *Symbolizer::PlatformDemangle(const char *name) { return nullptr; } namespace { struct ScopedHandle { diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_symbolizer_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_symbolizer_test.cpp index 1e70c146b46ce..b8267e4007997 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_symbolizer_test.cpp +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_symbolizer_test.cpp @@ -58,13 +58,13 @@ TEST(Symbolizer, ExtractTokenUpToDelimiter) { TEST(Symbolizer, DemangleSwiftAndCXX) { // Swift names are not demangled in default llvm build because Swift // runtime is not linked in. - EXPECT_STREQ("_TtSd", DemangleSwiftAndCXX("_TtSd")); + EXPECT_STREQ(nullptr, DemangleSwiftAndCXX("_TtSd")); // Check that the rest demangles properly. EXPECT_STREQ("f1(char*, int)", DemangleSwiftAndCXX("_Z2f1Pci")); #if !SANITIZER_FREEBSD // QoI issue with libcxxrt on FreeBSD - EXPECT_STREQ("foo", DemangleSwiftAndCXX("foo")); + EXPECT_STREQ(nullptr, DemangleSwiftAndCXX("foo")); #endif - EXPECT_STREQ("", DemangleSwiftAndCXX("")); + EXPECT_STREQ(nullptr, DemangleSwiftAndCXX("")); } #endif