diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-12-22 12:01:52 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-12-25 10:12:41 +0100 |
| commit | f8f67d67d3daa783c2bb7c9993c0ccb637af1a0e (patch) | |
| tree | d17cd1f31315f1466673d951dad6ee9e309d66ec /pkg/csource | |
| parent | 549d0d03df068e7cc1d48f92ba1ba76153c91339 (diff) | |
executor: remove hardcoded timeouts
In preparation for making timeouts tunable based
on OS/arch/VM/etc de-hardcode all (almost) timeouts in executor.
Diffstat (limited to 'pkg/csource')
| -rw-r--r-- | pkg/csource/csource.go | 3 | ||||
| -rw-r--r-- | pkg/csource/generated.go | 14 |
2 files changed, 12 insertions, 5 deletions
diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go index 49babbf41..b53b3b97f 100644 --- a/pkg/csource/csource.go +++ b/pkg/csource/csource.go @@ -93,13 +93,14 @@ func Write(p *prog.Prog, opts Options) ([]byte, error) { replacements["SANDBOX_FUNC"] = replacements["SYSCALLS"] replacements["SYSCALLS"] = "unused" } + replacements["PROGRAM_TIMEOUT_MS"] = "5000" timeoutExpr := "45" for i, call := range p.Calls { if timeout := call.Meta.Attrs.Timeout; timeout != 0 { timeoutExpr += fmt.Sprintf(" + (call == %d ? %d : 0)", i, timeout) } } - replacements["CALL_TIMEOUT"] = timeoutExpr + replacements["CALL_TIMEOUT_MS"] = timeoutExpr result, err := createCommonHeader(p, mmapProg, replacements, opts) if err != nil { return nil, err diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index 5f38c02c6..a1d204fd1 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -10093,7 +10093,7 @@ again: if (collide && (call % 2) == 0) break; #endif - event_timedwait(&th->done, /*{{{CALL_TIMEOUT}}}*/); + event_timedwait(&th->done, /*{{{CALL_TIMEOUT_MS}}}*/); break; } } @@ -10208,17 +10208,23 @@ static void loop(void) break; sleep_ms(1); #if SYZ_EXECUTOR && SYZ_EXECUTOR_USES_SHMEM + uint64 min_timeout_ms = program_timeout_ms * 3 / 5; + uint64 inactive_timeout_ms = syscall_timeout_ms * 20; uint64 now = current_time_ms(); uint32 now_executed = __atomic_load_n(output_data, __ATOMIC_RELAXED); if (executed_calls != now_executed) { executed_calls = now_executed; last_executed = now; } - if ((now - start < 5 * 1000) && (now - start < 3 * 1000 || now - last_executed < 1000)) + if ((now - start < program_timeout_ms) && + (now - start < min_timeout_ms || now - last_executed < inactive_timeout_ms)) continue; -#else - if (current_time_ms() - start < 5 * 1000) +#elif SYZ_EXECUTOR + if (current_time_ms() - start < program_timeout_ms) continue; +#else + if (current_time_ms() - start < /*{{{PROGRAM_TIMEOUT_MS}}}*/) + continue; #endif debug("killing hanging pid %d\n", pid); kill_and_wait(pid, &status); |
