This is an archive of the discontinued LLVM Phabricator instance.

[libFuzzer] Fix CFI Directives for fuchsia
ClosedPublic

Authored by charco on Jul 23 2021, 4:36 PM.

Details

Summary

This commit fixes the CFI directives in the crash trampoline so
libunwind can get a backtrace during a crash.

In order to get a backtrace from a libfuzzer crash in fuchsia, we
resume execution in the crashed thread, forcing it to call the
StaticCrashHandler. We do this by setting a "crash trampoline" that has
all the necessary cfi directives for an unwinder to get full backtrace
for that thread.

Due to a bug in libunwind, it was not possible to restore the RSP
pointer, as it was always set to the call frame address (CFA). The
previous version worked around this issue by setting the CFA to the
value of the stack pointer at the point of the crash.

The bug in libunwind is now fixed[0], so I am correcting the CFI
annotations so that the CFA correctly points to the beginning of the
trampoline's call frame.

[0]: https://reviews.llvm.org/D106626

Diff Detail

Event Timeline

charco requested review of this revision.Jul 23 2021, 4:36 PM
charco created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2021, 4:36 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
charco updated this revision to Diff 361382.Jul 23 2021, 4:41 PM

correct clang-format as it has no idea what it's doing.

This revision is now accepted and ready to land.Jul 27 2021, 4:38 PM
This revision was landed with ongoing or failed builds.Jul 28 2021, 5:59 PM
This revision was automatically updated to reflect the committed changes.