diff options
Diffstat (limited to 'executor/executor.cc')
| -rw-r--r-- | executor/executor.cc | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/executor/executor.cc b/executor/executor.cc index f0d32dcea..2635d5a7c 100644 --- a/executor/executor.cc +++ b/executor/executor.cc @@ -199,7 +199,6 @@ struct thread_t { uint32 reserrno; bool fault_injected; cover_t cov; - bool extra_cover; }; static thread_t threads[kMaxThreads]; @@ -288,7 +287,7 @@ struct feature_t { void (*setup)(); }; -static thread_t* schedule_call(int call_index, int call_num, bool colliding, uint64 copyout_index, uint64 num_args, uint64* args, uint64* pos, bool extra_cover); +static thread_t* schedule_call(int call_index, int call_num, bool colliding, uint64 copyout_index, uint64 num_args, uint64* args, uint64* pos); static void handle_completion(thread_t* th); static void copyout_call_results(thread_t* th); static void write_call_output(thread_t* th, bool finished); @@ -591,8 +590,8 @@ retry: } int call_index = 0; - bool prog_extra_cover = false; int prog_extra_timeout = 0; + int prog_extra_cover_timeout = 0; for (;;) { uint64 call_num = read_input(&input_pos); if (call_num == instr_eof) @@ -687,14 +686,11 @@ retry: // Normal syscall. if (call_num >= ARRAY_SIZE(syscalls)) fail("invalid command number %llu", call_num); - bool call_extra_cover = false; // call_extra_timeout must match timeout in pkg/csource/csource.go. int call_extra_timeout = 0; // TODO: find a way to tune timeout values. - if (strncmp(syscalls[call_num].name, "syz_usb", strlen("syz_usb")) == 0) { - prog_extra_cover = true; - call_extra_cover = true; - } + if (strncmp(syscalls[call_num].name, "syz_usb", strlen("syz_usb")) == 0) + prog_extra_cover_timeout = 500; if (strncmp(syscalls[call_num].name, "syz_usb_connect", strlen("syz_usb_connect")) == 0) { prog_extra_timeout = 2000; call_extra_timeout = 2000; @@ -721,7 +717,7 @@ retry: for (uint64 i = num_args; i < kMaxArgs; i++) args[i] = 0; thread_t* th = schedule_call(call_index++, call_num, colliding, copyout_index, - num_args, args, input_pos, call_extra_cover); + num_args, args, input_pos); if (colliding && (call_index % 2) == 0) { // Don't wait for every other call. @@ -779,8 +775,6 @@ retry: write_call_output(th, false); } } - if (prog_extra_cover) - write_extra_output(); } } @@ -788,10 +782,16 @@ retry: close_fds(); #endif - if (prog_extra_cover) { - sleep_ms(500); - if (!colliding && !collide) + if (!colliding && !collide) { + write_extra_output(); + // Check for new extra coverage in small intervals to avoid situation + // that we were killed on timeout before we write any. + // Check for extra coverage is very cheap, effectively a memory load. + const int kSleepMs = 100; + for (int i = 0; i < prog_extra_cover_timeout / kSleepMs; i++) { + sleep_ms(kSleepMs); write_extra_output(); + } } if (flag_collide && !flag_fault && !colliding && !collide) { @@ -801,7 +801,7 @@ retry: } } -thread_t* schedule_call(int call_index, int call_num, bool colliding, uint64 copyout_index, uint64 num_args, uint64* args, uint64* pos, bool extra_cover) +thread_t* schedule_call(int call_index, int call_num, bool colliding, uint64 copyout_index, uint64 num_args, uint64* args, uint64* pos) { // Find a spare thread to execute the call. int i; @@ -832,7 +832,6 @@ thread_t* schedule_call(int call_index, int call_num, bool colliding, uint64 cop th->num_args = num_args; for (int i = 0; i < kMaxArgs; i++) th->args[i] = args[i]; - th->extra_cover = extra_cover; event_set(&th->ready); running++; return th; @@ -891,8 +890,7 @@ void handle_completion(thread_t* th) copyout_call_results(th); if (!collide && !th->colliding) { write_call_output(th, true); - if (th->extra_cover) - write_extra_output(); + write_extra_output(); } th->executing = false; running--; |
