This is an archive of the discontinued LLVM Phabricator instance.

tsan: strip __libc_start_main frame
ClosedPublic

Authored by dvyukov on Jul 28 2021, 7:17 AM.

Details

Summary

We strip all frames below main but in some cases it may be not enough.
Namely, when main is instrumented but does not call any other instrumented code.
In this case tsan_func_entry in main obtains PC pointing to libc_start_main
(as we pass caller PC to tsan_func_entry), but nothing obtains PC pointing
to main itself (as main does not call any instrumented code).
In such case we will not have main in the stack, and stripping everything
below main won't work.
So strip
libc_start_main explicitly as well.
But keep stripping of main because __libc_start_main is glibc/linux-specific,
so looking for main is more reliable (and usually main is present in stacks).

Depends on D106957.

Diff Detail

Event Timeline

dvyukov requested review of this revision.Jul 28 2021, 7:17 AM
dvyukov created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2021, 7:17 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka accepted this revision.Jul 28 2021, 10:57 AM
vitalybuka added inline comments.
compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
72

To my taste this stripping adds no value.
Stripping of top internal frames makes sense, as usually users walk from the top to the frame relevant to the error.
As a user myself I am sometimes annoyed by top irrelevant frames. But I don't care about spam in the bottom.

This revision is now accepted and ready to land.Jul 28 2021, 10:57 AM
dvyukov added inline comments.Jul 28 2021, 11:21 AM
compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
72

Acknowledged

This revision was automatically updated to reflect the committed changes.