[compiler-rt] 6777919 - [libFuzzer] Remove InterruptHandler from Fuchsia implementation

Marco Vanotti via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 29 00:02:58 PDT 2020


Author: Cameron Finucane
Date: 2020-10-29T00:02:31-07:00
New Revision: 6777919d5ac2dfc9923bb5b0b366038ed7fa9621

URL: https://github.com/llvm/llvm-project/commit/6777919d5ac2dfc9923bb5b0b366038ed7fa9621
DIFF: https://github.com/llvm/llvm-project/commit/6777919d5ac2dfc9923bb5b0b366038ed7fa9621.diff

LOG: [libFuzzer] Remove InterruptHandler from Fuchsia implementation

As implemented, the `InterruptHandler` thread was spinning trying to
`select()` on a null "stdin", wasting a significant amount of CPU for no
benefit. As Fuchsia does not have a native concept of stdin (or POSIX
signals), this commit simply removes this feature entirely.

Reviewed By: aarongreen

Differential Revision: https://reviews.llvm.org/D89266

Added: 
    

Modified: 
    compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
index 93fa2f5a623d..af4394616776 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
@@ -68,17 +68,6 @@ void AlarmHandler(int Seconds) {
   }
 }
 
-void InterruptHandler() {
-  fd_set readfds;
-  // Ctrl-C sends ETX in Zircon.
-  do {
-    FD_ZERO(&readfds);
-    FD_SET(STDIN_FILENO, &readfds);
-    select(STDIN_FILENO + 1, &readfds, nullptr, nullptr, nullptr);
-  } while(!FD_ISSET(STDIN_FILENO, &readfds) || getchar() != 0x03);
-  Fuzzer::StaticInterruptCallback();
-}
-
 // CFAOffset is used to reference the stack pointer before entering the
 // trampoline (Stack Pointer + CFAOffset = prev Stack Pointer). Before jumping
 // to the trampoline we copy all the registers onto the stack. We need to make
@@ -359,11 +348,7 @@ void SetSignalHandler(const FuzzingOptions &Options) {
     T.detach();
   }
 
-  // Set up interrupt handler if needed.
-  if (Options.HandleInt || Options.HandleTerm) {
-    std::thread T(InterruptHandler);
-    T.detach();
-  }
+  // Options.HandleInt and Options.HandleTerm are not supported on Fuchsia
 
   // Early exit if no crash handler needed.
   if (!Options.HandleSegv && !Options.HandleBus && !Options.HandleIll &&


        


More information about the llvm-commits mailing list