[all-commits] [llvm/llvm-project] 5de8c7: [fuzzer][fuchsia] Close exception channel before e...
Aaron via All-commits
all-commits at lists.llvm.org
Thu Sep 16 11:57:36 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 5de8c7f1387dd5e2ad3b79a145baf41b21fa4952
https://github.com/llvm/llvm-project/commit/5de8c7f1387dd5e2ad3b79a145baf41b21fa4952
Author: Aaron Green <aarongreen at google.com>
Date: 2021-09-16 (Thu, 16 Sep 2021)
Changed paths:
M compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
Log Message:
-----------
[fuzzer][fuchsia] Close exception channel before exiting.
On Fuchsia, killing or exiting a process that has a thread listening to its own process's debugger exception channel can hang. Zircon may kill all the threads, send a synthetic exceptions to debugger, and wait for the debugger to have received them. This means the thread listening to the debug exception channel may be killed even as Zircon is waiting for that thread to drain the exception channel, and the process can become stuck in a half-dead state.
This situation is "weird" as it only arises when a process is trying to debug itself. Unfortunately, this is exactly the scenario for libFuzzer on Fuchsia: FuzzerUtilFuchsia spawns a crash-handling thread that acts like a debugger in order to be able to rewrite the crashed threads stack and resume them into libFuzzer's usual POSIX signal handlers. In practice, approximately 25% of fuzzers appear to hang on exit, after generating output and artifacts. These processes hang around until the platform is torn done, which is typically a ClusterFuzz VM. Thus, real-world impact has been somewhat mitigated. The issue should still be resolved for local users, though.
This change improves the behavior of exit() in libFuzzer by adding an atexit handler which closes an event shared with the crash handling thread. This signals to the crash handler that it should close the exception channel and be joined before the process actually exits.
Reviewed By: charco
Differential Revision: https://reviews.llvm.org/D109258
More information about the All-commits
mailing list