This is an archive of the discontinued LLVM Phabricator instance.

[NFC][Sanitizer] Cleanup GetStackTrace implementations
Changes PlannedPublic

Authored by yln on Feb 26 2019, 1:12 PM.

Details

Reviewers
vitalybuka
Summary

GetStackTrace implementations seem to have started out as exact copies
of the original implementation in ASan, but have diverged in subtle
ways. I left comments for these differences and will address them
according to your guidance in a follow-up patch.

Event Timeline

yln created this revision.Feb 26 2019, 1:12 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 26 2019, 1:12 PM
Herald added subscribers: llvm-commits, Restricted Project, kubamracek. · View Herald Transcript
vitalybuka added inline comments.Feb 26 2019, 1:57 PM
compiler-rt/lib/hwasan/hwasan.cc
247

It wold be nice to have this as multiple NFC patches:

  1. rename arguments
  2. move size=0 to top
  3. move SymbolizerScope sym_scope

...

as-is I am not 100% sure that this patch is NFC
with tiny patches it would be easier to nail accidental regression

251

it must be either CHECK_EQ(0, stack->size) or = 0
So I am fine as-is where we just let to reuse instance of BufferedStackTrace by resetting size

259

we don't need these local variables

compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
166

Can you please undo this macro? On first look I don't see value in them.
If you want to try convince me please try new patch with macro change only.

173

this UNREACHABLE can be a CHECK(SANITIZER_CAN_FAST_UNWIND) in UnwindFast

yln marked 4 inline comments as done.Feb 26 2019, 4:06 PM
yln added inline comments.
compiler-rt/lib/hwasan/hwasan.cc
259

Agreed. If this would be the final version, I would inline them.
My goal here was to make all GetStackTrace look the same. Do you see the pattern?
It would be nice if we could remove it altogether or at least make it a private helper of the BufferedStackTrace class.

compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
166

The only reason for these macros is that we can't directly do a call like stack->UnwindFast(..) from other code since it might not be available on a platform (not even a dummy symbol).

Let me know if you think that having dummy implementation that errors with "not supported" is preferred over having these macros.

173

I don't understand your comment.
UnwindFast is only available on SANITIZER_CAN_FAST_UNWIND platforms.

vitalybuka added inline comments.Feb 26 2019, 4:36 PM
compiler-rt/lib/hwasan/hwasan.cc
251

in other words, you can remove "investigate why this is needed" comment

259

acknowledged

compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
166

dummy implementation as we do for the rest of sanitizers

173

if we have an implementation that
sanity check in the UnwindFast/UnwindSlow:
CHECK(SANITIZER_CAN_FAST_UNWIND/SANITIZER_CAN_SLOW_UNWIND)

if we have dummy function:
UNREACHABLE("Fast unwinder is unsupported")

yln marked 10 inline comments as done.Feb 26 2019, 5:53 PM
yln added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
108

this bug is fixed

166

Note that the macro approach is what's currently there. These macros just make it more explicit. I am happy to change this over to defining dummy symbols. Can I do this as a follow-up?

yln marked an inline comment as done.Feb 26 2019, 5:56 PM
yln planned changes to this revision.Feb 27 2019, 6:07 PM