[PATCH] D138095: [asan] Keep Itanium mangled names in global metadata

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 15 23:22:33 PST 2022


MaskRay created this revision.
MaskRay added reviewers: Sanitizers, hctim, kstoimenov, vitalybuka.
Herald added subscribers: Enna1, StephenFan, hiraditya.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added projects: Sanitizers, LLVM.
Herald added a subscriber: llvm-commits.

The runtime calls `MaybeDemangleGlobalName` for error reporting and
`__cxxabiv1::__cxa_demangle` is called if available, so demanging Itanium
mangled names in global metadata is unnecessary and wastes data size.

Add `MaybeDemangleGlobalName` in ODR violation detection to support demangled
names in a suppressions file. `MaybeDemangleGlobalName` may call
`DemangleCXXABI` and leak memory. Use an internal allocation to prevent lsan
leak (in case there is no fatal asan error).

The debug feature `report_globals=2` prints information for all instrumented
global variables. `MaybeDemangleGlobalName` would be slow, so don't do that.
The output looks like `Added Global[0x56448f092d60]: beg=0x56448fa66d60 size=4/32 name=_ZL13test_global_2`
and I think the mangled name is fine.

Other mangled schemes e.g. Windows (see win-string-literal.ll) remain the
current behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138095

Files:
  compiler-rt/lib/asan/asan_globals.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
  compiler-rt/test/asan/TestCases/Linux/odr_indicators.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/AddressSanitizer/local_alias.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138095.475695.patch
Type: text/x-patch
Size: 5843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221116/fdc614ef/attachment.bin>


More information about the llvm-commits mailing list