[compiler-rt] [libfuzzer] use timer_create() instead of setitimer() for linux (PR #110274)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 5 23:56:55 PDT 2024
https://github.com/MinxuanZ updated https://github.com/llvm/llvm-project/pull/110274
>From c2293659408f6147ecf6d25a700baeb771d2bcfa Mon Sep 17 00:00:00 2001
From: magus <manypotatoes1 at gmail.com>
Date: Fri, 27 Sep 2024 17:29:39 +0800
Subject: [PATCH] [libfuzzer] use timer_create() instead of setitimer() for
linux
---
compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
index 392c1e5be4eea3..469e4ed0661908 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
@@ -104,11 +104,16 @@ 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);
+ if (timer_create(CLOCK_REALTIME, NULL, &timerid) == -1) {
+ Printf("libFuzzer: timer_create failed with %d\n", errno);
+ exit(1);
+ }
+ if (timer_settime(timerid, 0, &T, NULL) == -1) {
+ Printf("libFuzzer: timer_settime failed with %d\n", errno);
exit(1);
}
SetSigaction(SIGALRM, AlarmHandler);
More information about the llvm-commits
mailing list