Index: lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc =================================================================== --- lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc +++ lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc @@ -50,6 +50,13 @@ // Attempts to demangle the name via __cxa_demangle from __cxxabiv1. const char *DemangleCXXABI(const char *name) { + if (!name) return nullptr; + + // Check if we are dealing with a C++ mangled name first. + if (name[0] != '_' || name[1] != 'Z') { + return nullptr; + } + // FIXME: __cxa_demangle aggressively insists on allocating memory. // There's not much we can do about that, short of providing our // own demangler (libc++abi's implementation could be adapted so that @@ -60,7 +67,7 @@ __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 @@ -98,7 +105,9 @@ if (!name) return nullptr; if (const char *swift_demangled_name = DemangleSwift(name)) return swift_demangled_name; - return DemangleCXXABI(name); + if (const char *cxx_demangled_name = DemangleCXXABI(name)) + return cxx_demangled_name; + return name; } bool SymbolizerProcess::StartSymbolizerSubprocess() {