Skip to content

Commit 7f3980a

Browse files
authored
[Fuzzer] Use user signal to coordinate handler shutdown (#82067)
This updates the signal handle thread coordinating to use a user signal bit on the SignalHandlerEvent to coordinate shutdown instead of closing the event handle. Closing the event handle is racy as the handle may be closed before the signal handler thread resolves the handle value in _zx_object_wait_many() and we would like to make this an explicit error. Using the user signal bit 1 instead and then closing the event object after the signal handler thread is joined cannot race as the wait will terminate whether the signal is raised before or after the wait begins.
1 parent d2942a8 commit 7f3980a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ void CrashHandler() {
292292
zx_wait_item_t WaitItems[] = {
293293
{
294294
.handle = SignalHandlerEvent,
295-
.waitfor = ZX_SIGNAL_HANDLE_CLOSED,
295+
.waitfor = ZX_USER_SIGNAL_1,
296296
.pending = 0,
297297
},
298298
{
@@ -378,10 +378,11 @@ void CrashHandler() {
378378
}
379379

380380
void StopSignalHandler() {
381-
_zx_handle_close(SignalHandlerEvent);
381+
_zx_object_signal(SignalHandlerEvent, 0, ZX_USER_SIGNAL_1);
382382
if (SignalHandler.joinable()) {
383383
SignalHandler.join();
384384
}
385+
_zx_handle_close(SignalHandlerEvent);
385386
}
386387

387388
} // namespace

0 commit comments

Comments
 (0)