Fix all deadlock issues known so far #11
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the deadlocks we’ve seen by switching LibAFL multiprocessing from
fork()-based clients to an exec-based Launcher mode (re-execing the same binary for each client).With a Go target linked via
-buildmode=c-archive, the Go runtime is initialized automatically via a global constructor (.init_array) beforemain. That turns the process into a multi-threaded runtime (GC workers, sysmon/netpoll, cgo init, etc.) that relies on background threads and synchronization primitives to make progress. If theLauncherspawns clients usingfork(). the child inherits a snapshot of this runtime state but not the threads that are supposed to drive it, so waits/condvars/channels can never be satisfied and the clients deadlock (e.g. cgo runtime init barriers, GC worker startup, andexec.Commandinternals).Using exec-based clients avoids inheriting a partially-initialized Go runtime across
fork(). Each fuzzing client now starts from a fresh process image and initializes Go normally, eliminating these deadlocks.Based on very minor testing, there is also a speed improvement which I think is caused by the fuzzing client not having to restart when the memory limits we set are hit and possibly also improvements internally to LibAFL.
Running the
caddyharness with 4 clients for 1 minute prior to change:After (roughly 6.8k exec/s better):
Note: Using a commit hash from LibAFL for now, since the
forkruntime flag has only recently been added. Will change this to a proper version once a new release is out.