This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer_common] Support stripping interceptor prefixes in RenderFrame()
ClosedPublic

Authored by melver on May 24 2023, 5:12 AM.

Details

Summary

Rather than having every tool pass the right interceptor prefix, just
move this logic into RenderFrame().

Note that currently there are a few cases where due to aliasing the
intercepted function -> interceptor, the unwinder sees the intercepted
function - however this is never guaranteed. In a later change this
becomes more apparent, and other non-tsan sanitizer tests would fail as
well. By making the default RenderFrame() strip interceptor prefixes, we
don't rely on the linker aliasing preferences.

Depends on D151318

Diff Detail

Event Timeline

melver created this revision.May 24 2023, 5:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2023, 5:12 AM
Herald added a subscriber: Enna1. · View Herald Transcript
melver requested review of this revision.May 24 2023, 5:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2023, 5:12 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
dvyukov added inline comments.May 24 2023, 5:18 AM
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
36

Do we now pass custom prefix anywhere? Or is it only for tests?

melver added inline comments.May 24 2023, 5:22 AM
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
36

Looks like it's only used in tests now. Should we just remove the argument completely?

dvyukov added inline comments.May 24 2023, 5:23 AM
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
36

Yes, I think it's better to test actual production code.

melver updated this revision to Diff 525169.May 24 2023, 7:19 AM
melver marked 2 inline comments as done.
melver edited the summary of this revision. (Show Details)
  • Remove unused RenderFrame arg.
  • Update test.
dvyukov accepted this revision.May 24 2023, 7:38 AM
This revision is now accepted and ready to land.May 24 2023, 7:38 AM
melver updated this revision to Diff 525200.May 24 2023, 8:52 AM
  • Fix formatting.
vitalybuka accepted this revision.May 24 2023, 6:14 PM
MaskRay accepted this revision.May 24 2023, 8:32 PM
MaskRay added a subscriber: MaskRay.
MaskRay added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp
22–38

Strip. Imperative sentences are common in llvm-project's comments.

melver updated this revision to Diff 525483.May 25 2023, 1:30 AM
melver marked an inline comment as done.
  • Strips -> Strip
This revision was landed with ongoing or failed builds.May 25 2023, 3:02 AM
This revision was automatically updated to reflect the committed changes.

I think this patch (or one of your other ones submitted together) broke the buildbot - the change is good but a test needs updating:

e.g., https://lab.llvm.org/buildbot/#/builders/127/builds/48810 (all the changes are part of the same series):

C:/b/slave/sanitizer-windows/llvm-project/compiler-rt/lib/sanitizer_common/tests/sanitizer_stacktrace_printer_test.cpp:104
Expected equality of these values:
  "% Frame:42 PC:0x400000 Module:my/module ModuleOffset:0x200 " "Function:bar FunctionOffset:0x100 Source:my/source Line:10 " "Column:5"
    Which is: "% Frame:42 PC:0x400000 Module:my/module ModuleOffset:0x200 Function:bar FunctionOffset:0x100 Source:my/source Line:10 Column:5"
  str.data()
    Which is: "% Frame:42 PC:0x400000 Module:my/module ModuleOffset:0x200 Function:__asan_wrap_bar FunctionOffset:0x100 Source:my/source Line:10 Column:5"

I think this patch (or one of your other ones submitted together) broke the buildbot - the change is good but a test needs updating:

e.g., https://lab.llvm.org/buildbot/#/builders/127/builds/48810 (all the changes are part of the same series):

C:/b/slave/sanitizer-windows/llvm-project/compiler-rt/lib/sanitizer_common/tests/sanitizer_stacktrace_printer_test.cpp:104
Expected equality of these values:
  "% Frame:42 PC:0x400000 Module:my/module ModuleOffset:0x200 " "Function:bar FunctionOffset:0x100 Source:my/source Line:10 " "Column:5"
    Which is: "% Frame:42 PC:0x400000 Module:my/module ModuleOffset:0x200 Function:bar FunctionOffset:0x100 Source:my/source Line:10 Column:5"
  str.data()
    Which is: "% Frame:42 PC:0x400000 Module:my/module ModuleOffset:0x200 Function:__asan_wrap_bar FunctionOffset:0x100 Source:my/source Line:10 Column:5"

This should already be fixed: https://github.com/llvm/llvm-project/commit/4c46c7cef3791a410cf226f7f005231be35dd8b9

This comment was removed by thurston.

I see, thanks Marco for the quick reply!

I think this patch (or one of your other ones submitted together) broke the buildbot - the change is good but a test needs updating:

e.g., https://lab.llvm.org/buildbot/#/builders/127/builds/48810 (all the changes are part of the same series):

C:/b/slave/sanitizer-windows/llvm-project/compiler-rt/lib/sanitizer_common/tests/sanitizer_stacktrace_printer_test.cpp:104
Expected equality of these values:
  "% Frame:42 PC:0x400000 Module:my/module ModuleOffset:0x200 " "Function:bar FunctionOffset:0x100 Source:my/source Line:10 " "Column:5"
    Which is: "% Frame:42 PC:0x400000 Module:my/module ModuleOffset:0x200 Function:bar FunctionOffset:0x100 Source:my/source Line:10 Column:5"
  str.data()
    Which is: "% Frame:42 PC:0x400000 Module:my/module ModuleOffset:0x200 Function:__asan_wrap_bar FunctionOffset:0x100 Source:my/source Line:10 Column:5"

This should already be fixed: https://github.com/llvm/llvm-project/commit/4c46c7cef3791a410cf226f7f005231be35dd8b9

gulfem added a subscriber: gulfem.May 25 2023, 9:54 AM

We started seeing the following failure in our Clang Toolchain builders:

[1576/1617](6) Linking CXX shared library /b/s/w/ir/x/w/staging/llvm_build/lib/clang/17/lib/x86_64-unknown-fuchsia/libclang_rt.hwasan.so
FAILED: /b/s/w/ir/x/w/staging/llvm_build/lib/clang/17/lib/x86_64-unknown-fuchsia/libclang_rt.hwasan.so
ld.lld: error: undefined symbol: __sanitizer::RenderFrame(__sanitizer::InternalScopedString*, char const*, int, unsigned long, __sanitizer::AddressInfo const*, bool, char const*)

https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8780110002348293249/+/u/clang/build/stdout

Here is our CMake commands:
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8780133481341449745/+/u/clang/configure/execution_details

We started seeing the following failure in our Clang Toolchain builders:

[1576/1617](6) Linking CXX shared library /b/s/w/ir/x/w/staging/llvm_build/lib/clang/17/lib/x86_64-unknown-fuchsia/libclang_rt.hwasan.so
FAILED: /b/s/w/ir/x/w/staging/llvm_build/lib/clang/17/lib/x86_64-unknown-fuchsia/libclang_rt.hwasan.so
ld.lld: error: undefined symbol: __sanitizer::RenderFrame(__sanitizer::InternalScopedString*, char const*, int, unsigned long, __sanitizer::AddressInfo const*, bool, char const*)

https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8780110002348293249/+/u/clang/build/stdout

Here is our CMake commands:
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8780133481341449745/+/u/clang/configure/execution_details

Thanks for the report. This should be fixed now: https://reviews.llvm.org/rG150470a055d5

We started seeing the following failure in our Clang Toolchain builders:

[1576/1617](6) Linking CXX shared library /b/s/w/ir/x/w/staging/llvm_build/lib/clang/17/lib/x86_64-unknown-fuchsia/libclang_rt.hwasan.so
FAILED: /b/s/w/ir/x/w/staging/llvm_build/lib/clang/17/lib/x86_64-unknown-fuchsia/libclang_rt.hwasan.so
ld.lld: error: undefined symbol: __sanitizer::RenderFrame(__sanitizer::InternalScopedString*, char const*, int, unsigned long, __sanitizer::AddressInfo const*, bool, char const*)

https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8780110002348293249/+/u/clang/build/stdout

Here is our CMake commands:
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8780133481341449745/+/u/clang/configure/execution_details

Thanks for the report. This should be fixed now: https://reviews.llvm.org/rG150470a055d5

Thanks! I'm confirming that it fixed our issue.