This is an archive of the discontinued LLVM Phabricator instance.

[libfuzzer] Handle more than one exception in Fuchsia.
AcceptedPublic

Authored by charco on Jul 28 2021, 7:36 PM.

Details

Summary

This change modifies FuzzerUtilFuchsia so that it can handle more than
one exception from the fuzzed threads.

The current implementation restores each thread that generates an
exception, making it go through a crash trampoline. There are two
problems with that approach:

  • We don't know what happens if two threads crash at the same time, as the trampoline code is not marked as thread-safe. The stored crash artifact might be invalid, as well as the backtrace.
  • If the StaticCrashHandler crashes (i.e: a thread crashes while it is handling the exception), it would be resumed in the StaticCrashHandler again, and that would most probably cause another crash, and an infinite loop, which would be eventually caught by the fuzzer timeout.

The new proposed change, keeps track of the first thread id that caused
an exception. New exceptions that come from different thread ids are not
processed (meaning that those thread would remain suspended). If a new
exception comes from the same thread id as the first exception, then we
just exit the fuzzer. This will cause a crash artifact to be generated.

To make this change work, there's a refactor on the ScopedHandle struct,
to make it a movable object, so the handles can be stored in a vector
and don't get closed.

Diff Detail

Event Timeline

charco requested review of this revision.Jul 28 2021, 7:36 PM
charco created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2021, 7:36 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
charco updated this revision to Diff 362609.Jul 28 2021, 7:37 PM

Fix typo

This revision is now accepted and ready to land.Aug 25 2021, 2:57 PM