[Fuzzer] Improve crash unwinding on Fuchsia
authorPetr Hosek <phosek@chromium.org>
Wed, 18 Jul 2018 19:20:47 +0000 (19:20 +0000)
committerPetr Hosek <phosek@chromium.org>
Wed, 18 Jul 2018 19:20:47 +0000 (19:20 +0000)
commit4915d3a1ec3e7d3542aafd05487f7e8246460f4a
tree5b56fb3ee52db4afc6f4c34b6ad32d26b172ef46
parent3a37cb54e02ca07ea0774f2588604feee6e9fba7
[Fuzzer] Improve crash unwinding on Fuchsia

Fuchsia doesn't have signals; instead it expects processes to have a
dedicated exception thread that binds to the process' exception port and
waits for exception packets to be delivered. On the other hand,
libFuzzer and sanitizer_common use expect to collect crash information
via libunwind from the same thread that caused the exception.

The long term fix is to improve support for remote unwinding in
libunbwind, plumb this through sanitizer_common and libFuzzer, and
handle the exception exclusively on the exception thread. In the
meantime, this revision has the exception thread "resurrect" the
crashing thread by:

* saving its general purpose register state onto the crashing thread's
  stack,
* setting the crashing thread's program counter to an assembly trampoline
  with the CFI information needed by libunwind, and
* resuming the crashed thread.

Patch By: aarongreen

Differential Revision: https://reviews.llvm.org/D48509

llvm-svn: 337418
compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp