MCPcopy Create free account
hub / github.com/HexHive/NASS / SetSignalHandler

Function SetSignalHandler

fuzz/libfuzzer/FuzzerUtilFuchsia.cpp:391–425  ·  view source on GitHub ↗

Platform specific functions.

Source from the content-addressed store, hash-verified

389
390// Platform specific functions.
391void SetSignalHandler(const FuzzingOptions &Options) {
392 // Make sure information from libFuzzer and the sanitizers are easy to
393 // reassemble. `__sanitizer_log_write` has the added benefit of ensuring the
394 // DSO map is always available for the symbolizer.
395 // A uint64_t fits in 20 chars, so 64 is plenty.
396 char Buf[64];
397 memset(Buf, 0, sizeof(Buf));
398 snprintf(Buf, sizeof(Buf), "==%lu== INFO: libFuzzer starting.\n", GetPid());
399 if (EF->__sanitizer_log_write)
400 __sanitizer_log_write(Buf, sizeof(Buf));
401 Printf("%s", Buf);
402
403 // Set up alarm handler if needed.
404 if (Options.HandleAlrm && Options.UnitTimeoutSec > 0) {
405 std::thread T(AlarmHandler, Options.UnitTimeoutSec / 2 + 1);
406 T.detach();
407 }
408
409 // Options.HandleInt and Options.HandleTerm are not supported on Fuchsia
410
411 // Early exit if no crash handler needed.
412 if (!Options.HandleSegv && !Options.HandleBus && !Options.HandleIll &&
413 !Options.HandleFpe && !Options.HandleAbrt)
414 return;
415
416 // Set up the crash handler and wait until it is ready before proceeding.
417 ExitOnErr(_zx_event_create(0, &SignalHandlerEvent), "_zx_event_create");
418
419 SignalHandler = std::thread(CrashHandler);
420 zx_status_t Status = _zx_object_wait_one(SignalHandlerEvent, ZX_USER_SIGNAL_0,
421 ZX_TIME_INFINITE, nullptr);
422 ExitOnErr(Status, "_zx_object_wait_one");
423
424 std::atexit(StopSignalHandler);
425}
426
427void SleepSeconds(int Seconds) {
428 _zx_nanosleep(_zx_deadline_after(ZX_SEC(Seconds)));

Callers

nothing calls this directly

Calls 4

ExitOnErrFunction · 0.85
detachMethod · 0.80
GetPidFunction · 0.70
PrintfFunction · 0.70

Tested by

no test coverage detected