This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Skip stack symbolization when not required for print format
ClosedPublic

Authored by tejohnson on Sep 26 2020, 8:30 AM.

Details

Summary

Adds a check to avoid symbolization when printing stack traces if the
stack_trace_format flag does not need it. While there is a symbolize
flag that can be turned off to skip some of the symbolization,
SymbolizePC() still unconditionally looks up the module name and offset.
Avoid invoking SymbolizePC() at all if not needed.

This is an efficiency improvement when dumping all stack traces as part
of the memory profiler in D87120, for large stripped apps where we want
to symbolize as a post pass.

Diff Detail

Event Timeline

tejohnson created this revision.Sep 26 2020, 8:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 26 2020, 8:30 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
tejohnson requested review of this revision.Sep 26 2020, 8:30 AM
vitalybuka accepted this revision.Sep 30 2020, 5:44 PM
This revision is now accepted and ready to land.Sep 30 2020, 5:44 PM
vitalybuka added inline comments.Sep 30 2020, 5:51 PM
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
109–111

maybe
and pass info as nullptr for frames without symbolization call
to crash if RenderNeedsSymbolization was wrong.

tejohnson marked an inline comment as done.Oct 7 2020, 2:36 PM
tejohnson updated this revision to Diff 296795.Oct 7 2020, 2:37 PM

Implement suggestion

This revision was landed with ongoing or failed builds.Oct 7 2020, 3:39 PM
This revision was automatically updated to reflect the committed changes.

Hi! It seems that this change is leading to the undefined symbol errors we're seeing on our builders (https://luci-milo.appspot.com/p/fuchsia/builders/ci/clang-linux-x64/b8867057367989385504):

[716/753] Linking CXX shared library /b/s/w/ir/x/w/staging/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.asan.so
FAILED: /b/s/w/ir/x/w/staging/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.asan.so 
...
ld.lld: error: undefined symbol: __sanitizer::RenderNeedsSymbolization(char const*)
>>> referenced by sanitizer_stacktrace_libcdep.cpp:29 (compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:29)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj:(__sanitizer::StackTrace::Print() const)
>>> referenced by sanitizer_stacktrace_libcdep.cpp:118 (compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:118)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj:(__sanitizer_symbolize_pc)

ld.lld: error: undefined symbol: __sanitizer::RenderFrame(__sanitizer::InternalScopedString*, char const*, int, unsigned long, __sanitizer::AddressInfo const*, bool, char const*, char const*)
>>> referenced by sanitizer_stacktrace_libcdep.cpp:43 (compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:43)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj:(__sanitizer::StackTrace::Print() const)
>>> referenced by sanitizer_stacktrace_libcdep.cpp:135 (compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:135)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj:(__sanitizer_symbolize_pc)
>>> referenced by sanitizer_symbolizer_report.cpp:36 (compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp:36)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_report.cpp.obj:(__sanitizer::ReportErrorSummary(char const*, __sanitizer::AddressInfo const&, char const*))

Could you take a look? Thanks.

Hi! It seems that this change is leading to the undefined symbol errors we're seeing on our builders (https://luci-milo.appspot.com/p/fuchsia/builders/ci/clang-linux-x64/b8867057367989385504):

[716/753] Linking CXX shared library /b/s/w/ir/x/w/staging/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.asan.so
FAILED: /b/s/w/ir/x/w/staging/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.asan.so 
...
ld.lld: error: undefined symbol: __sanitizer::RenderNeedsSymbolization(char const*)
>>> referenced by sanitizer_stacktrace_libcdep.cpp:29 (compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:29)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj:(__sanitizer::StackTrace::Print() const)
>>> referenced by sanitizer_stacktrace_libcdep.cpp:118 (compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:118)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj:(__sanitizer_symbolize_pc)

ld.lld: error: undefined symbol: __sanitizer::RenderFrame(__sanitizer::InternalScopedString*, char const*, int, unsigned long, __sanitizer::AddressInfo const*, bool, char const*, char const*)
>>> referenced by sanitizer_stacktrace_libcdep.cpp:43 (compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:43)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj:(__sanitizer::StackTrace::Print() const)
>>> referenced by sanitizer_stacktrace_libcdep.cpp:135 (compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:135)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj:(__sanitizer_symbolize_pc)
>>> referenced by sanitizer_symbolizer_report.cpp:36 (compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp:36)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_report.cpp.obj:(__sanitizer::ReportErrorSummary(char const*, __sanitizer::AddressInfo const&, char const*))

Could you take a look? Thanks.

I see the issue. Fuschia uses a different implementation of RenderFrame, I'll need to update that one too and add a dummy version of the new RenderNeedsSymbolization as well (looks like this version in sanitizer_symbolizer_markup.cpp is quite simple and doesn't attempt to symbolize at all, so RenderNeedsSymbolization can simply return false). Fix coming up.

Hi! It seems that this change is leading to the undefined symbol errors we're seeing on our builders (https://luci-milo.appspot.com/p/fuchsia/builders/ci/clang-linux-x64/b8867057367989385504):

[716/753] Linking CXX shared library /b/s/w/ir/x/w/staging/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.asan.so
FAILED: /b/s/w/ir/x/w/staging/llvm_build/lib/clang/12.0.0/lib/x86_64-unknown-fuchsia/libclang_rt.asan.so 
...
ld.lld: error: undefined symbol: __sanitizer::RenderNeedsSymbolization(char const*)
>>> referenced by sanitizer_stacktrace_libcdep.cpp:29 (compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:29)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj:(__sanitizer::StackTrace::Print() const)
>>> referenced by sanitizer_stacktrace_libcdep.cpp:118 (compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:118)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj:(__sanitizer_symbolize_pc)

ld.lld: error: undefined symbol: __sanitizer::RenderFrame(__sanitizer::InternalScopedString*, char const*, int, unsigned long, __sanitizer::AddressInfo const*, bool, char const*, char const*)
>>> referenced by sanitizer_stacktrace_libcdep.cpp:43 (compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:43)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj:(__sanitizer::StackTrace::Print() const)
>>> referenced by sanitizer_stacktrace_libcdep.cpp:135 (compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:135)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_stacktrace_libcdep.cpp.obj:(__sanitizer_symbolize_pc)
>>> referenced by sanitizer_symbolizer_report.cpp:36 (compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp:36)
>>>               compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.x86_64.dir/sanitizer_symbolizer_report.cpp.obj:(__sanitizer::ReportErrorSummary(char const*, __sanitizer::AddressInfo const&, char const*))

Could you take a look? Thanks.

I see the issue. Fuschia uses a different implementation of RenderFrame, I'll need to update that one too and add a dummy version of the new RenderNeedsSymbolization as well (looks like this version in sanitizer_symbolizer_markup.cpp is quite simple and doesn't attempt to symbolize at all, so RenderNeedsSymbolization can simply return false). Fix coming up.

Should be fixed by f775cb8994ccb367d68cdea5ce453d747e47d891.

Should be fixed by f775cb8994ccb367d68cdea5ce453d747e47d891.

Awesome! Thanks for the quick fix.