Skip to content

[libfuzzer] use timer_create() instead of setitimer() for linux #110274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,19 @@ bool ExecuteCommand(const Command &Cmd, std::string *CmdOutput) {
}

void SetTimer(int Seconds) {
struct itimerval T {
timer_t TimerId;
struct itimerspec T {
{Seconds, 0}, { Seconds, 0 }
};
if (setitimer(ITIMER_REAL, &T, nullptr)) {
Printf("libFuzzer: setitimer failed with %d\n", errno);
SetSigaction(SIGALRM, AlarmHandler);
if (timer_create(CLOCK_REALTIME, nullptr, &TimerId) == -1) {
Printf("libFuzzer: timer_create failed with %d\n", errno);
exit(1);
}
if (timer_settime(TimerId, 0, &T, nullptr) == -1) {
Printf("libFuzzer: timer_settime failed with %d\n", errno);
exit(1);
}
SetSigaction(SIGALRM, AlarmHandler);
}

void SetSignalHandler(const FuzzingOptions& Options) {
Expand Down
Loading