This is an archive of the discontinued LLVM Phabricator instance.

[asan_symbolize] Fix bug handling C++ symbols when using Atos.
ClosedPublic

Authored by delcypher on May 7 2020, 2:06 PM.

Details

Summary

The previous code tries to strip out parentheses and anything in between
them. I'm guessing the idea here was to try to drop any listed arguments
for the function being symbolized. Unfortunately this approach is broken
in several ways.

  • Templated functions may contain parentheses. The existing approach

messes up these names.

  • In C++ argument types are part of a function's signature for the

purposes of overloading so removing them could be confusing.

Fix this simply by not trying to adjust the function name that comes
from atos.

A test case is included.

Without the change the test case produced output like:

WRITE of size 4 at 0x6060000001a0 thread T0
    #0 0x10b96614d in IntWrapper<void >::operator=> const&) asan-symbolize-templated-cxx.cpp:10
    #1 0x10b960b0e in void writeToA<IntWrapper<void > >>) asan-symbolize-templated-cxx.cpp:30
    #2 0x10b96bf27 in decltype>)>> >)) std::__1::__invoke<void >), IntWrapper<void > >>), IntWrapper<void >&&) type_traits:4425
    #3 0x10b96bdc1 in void std::__1::__invoke_void_return_wrapper<void>::__call<void >), IntWrapper<void > >>), IntWrapper<void >&&) __functional_base:348
    #4 0x10b96bd71 in std::__1::__function::__alloc_func<void >), std::__1::allocator<void >)>, void >)>::operator>&&) functional:1533
    #5 0x10b9684e2 in std::__1::__function::__func<void >), std::__1::allocator<void >)>, void >)>::operator>&&) functional:1707
    #6 0x10b96cd7b in std::__1::__function::__value_func<void >)>::operator>&&) const functional:1860
    #7 0x10b96cc17 in std::__1::function<void >)>::operator>) const functional:2419
    #8 0x10b960ca6 in Foo<void >), IntWrapper<void > >::doCall>) asan-symbolize-templated-cxx.cpp:44
    #9 0x10b96088b in main asan-symbolize-templated-cxx.cpp:54
    #10 0x7fff6ffdfcc8 in start (in libdyld.dylib) + 0

Note how the symbol names for the frames are messed up (e.g. #8, #1).

With the patch the output looks like:

WRITE of size 4 at 0x6060000001a0 thread T0
    #0 0x10005214d in IntWrapper<void (int)>::operator=(IntWrapper<void (int)> const&) asan-symbolize-templated-cxx.cpp:10
    #1 0x10004cb0e in void writeToA<IntWrapper<void (int)> >(IntWrapper<void (int)>) asan-symbolize-templated-cxx.cpp:30
    #2 0x100057f27 in decltype(std::__1::forward<void (*&)(IntWrapper<void (int)>)>(fp)(std::__1::forward<IntWrapper<void (int)> >(fp0))) std::__1::__invoke<void (*&)(IntWrapper<void (int)>), IntWrapper<void (int)> >(void (*&)(IntWrapper<void (int)>), IntWrapper<void (int)>&&) type_traits:4425
    #3 0x100057dc1 in void std::__1::__invoke_void_return_wrapper<void>::__call<void (*&)(IntWrapper<void (int)>), IntWrapper<void (int)> >(void (*&)(IntWrapper<void (int)>), IntWrapper<void (int)>&&) __functional_base:348
    #4 0x100057d71 in std::__1::__function::__alloc_func<void (*)(IntWrapper<void (int)>), std::__1::allocator<void (*)(IntWrapper<void (int)>)>, void (IntWrapper<void (int)>)>::operator()(IntWrapper<void (int)>&&) functional:1533
    #5 0x1000544e2 in std::__1::__function::__func<void (*)(IntWrapper<void (int)>), std::__1::allocator<void (*)(IntWrapper<void (int)>)>, void (IntWrapper<void (int)>)>::operator()(IntWrapper<void (int)>&&) functional:1707
    #6 0x100058d7b in std::__1::__function::__value_func<void (IntWrapper<void (int)>)>::operator()(IntWrapper<void (int)>&&) const functional:1860
    #7 0x100058c17 in std::__1::function<void (IntWrapper<void (int)>)>::operator()(IntWrapper<void (int)>) const functional:2419
    #8 0x10004cca6 in Foo<void (IntWrapper<void (int)>), IntWrapper<void (int)> >::doCall(IntWrapper<void (int)>) asan-symbolize-templated-cxx.cpp:44
    #9 0x10004c88b in main asan-symbolize-templated-cxx.cpp:54
    #10 0x7fff6ffdfcc8 in start (in libdyld.dylib) + 0

rdar://problem/58887175

Diff Detail

Event Timeline

delcypher created this revision.May 7 2020, 2:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 7 2020, 2:06 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
yln added a comment.May 8 2020, 1:12 PM

LGTM with suggested update for the comment. Thanks!

I'm guessing the idea here was to try to drop any listed arguments for the function being symbolized.

If you are able to find out why this was done quickly (in a few minutes), then please document the reason here in this review thread.

compiler-rt/lib/asan/scripts/asan_symbolize.py
281
* For C functions atos omits parentheses and argument types.
* For C++ functions the function name (i.e., `foo` above) may contain templates which may contain parentheses.
yln accepted this revision.May 8 2020, 1:13 PM
This revision is now accepted and ready to land.May 8 2020, 1:13 PM
delcypher updated this revision to Diff 265078.May 19 2020, 4:06 PM

Tweak comment per feedback.

delcypher marked an inline comment as done.May 19 2020, 4:06 PM
In D79597#2027534, @yln wrote:

LGTM with suggested update for the comment. Thanks!

I'm guessing the idea here was to try to drop any listed arguments for the function being symbolized.

If you are able to find out why this was done quickly (in a few minutes), then please document the reason here in this review thread.

I couldn't figure out why this was done based on git blame.

This revision was automatically updated to reflect the committed changes.