Skip to content

Commit 5c3d629

Browse files
committed
Revert "Use InernalAlloc in DemangleCXXABI"
This reverts commit 649004a. This commit caused regression in TSAN tests on Darwin: https://green.lab.llvm.org/green/job/clang-stage1-RA/35380/ These tests have been failing: SanitizerCommon-tsan-x86_64-Darwin.Darwin.symbolizer-function-offset-dladdr.cpp SanitizerCommon-tsan-x86_64h-Darwin.Darwin.symbolizer-function-offset-dladdr.cpp ThreadSanitizer-x86_64.Darwin.symbolizer-dladdr.cpp ThreadSanitizer-x86_64h.Darwin.symbolizer-dladdr.cpp
1 parent 3e50bcb commit 5c3d629

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,15 @@ namespace __sanitizer {
4646

4747
// Attempts to demangle the name via __cxa_demangle from __cxxabiv1.
4848
const char *DemangleCXXABI(const char *name) {
49-
// __cxa_demangle aggressively insists on allocating memory.
49+
// FIXME: __cxa_demangle aggressively insists on allocating memory.
5050
// There's not much we can do about that, short of providing our
5151
// own demangler (libc++abi's implementation could be adapted so that
52-
// it does not allocate). For now, we just call it anyway, and use
53-
// InternalAlloc to prevent lsan error.
54-
if (&__cxxabiv1::__cxa_demangle) {
55-
if (char *demangled_name = __cxxabiv1::__cxa_demangle(name, 0, 0, 0)) {
56-
size_t size = internal_strlen(demangled_name) + 1;
57-
char *buf = (char *)InternalAlloc(size);
58-
internal_memcpy(buf, demangled_name, size);
59-
free(demangled_name);
60-
return buf;
61-
}
62-
}
52+
// it does not allocate). For now, we just call it anyway, and we leak
53+
// the returned value.
54+
if (&__cxxabiv1::__cxa_demangle)
55+
if (const char *demangled_name =
56+
__cxxabiv1::__cxa_demangle(name, 0, 0, 0))
57+
return demangled_name;
6358

6459
return name;
6560
}

0 commit comments

Comments
 (0)