aboutsummaryrefslogtreecommitdiffstats
path: root/executor/executor.cc
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-05-31 11:16:40 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-06-03 10:06:46 +0000
commit720b7efa99d7f3b4069af440ea7d004a6f27467d (patch)
treea812d72870d72580cf4b902d00fc2e9cf14fd122 /executor/executor.cc
parentd2862abe19f233f936ad61550df88db5b41049c8 (diff)
executor: rework feature setup
Return failure reason from setup functions rather than crash. This will provide better error messages, but also allow setup w/o creating subprocesses which will be needed when we combine fuzzer and executor. Also close all resources created during setup. This is also useful for in-process setup, but also should improve chances of reproducing a bug with C reproducer. Currently leaked file descriptors may disturb repro execution (e.g. it may act on a wrong fd).
Diffstat (limited to 'executor/executor.cc')
-rw-r--r--executor/executor.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/executor/executor.cc b/executor/executor.cc
index 71a376870..d5420e90c 100644
--- a/executor/executor.cc
+++ b/executor/executor.cc
@@ -370,7 +370,7 @@ typedef char kcov_comparison_size[sizeof(kcov_comparison_t) == 4 * sizeof(uint64
struct feature_t {
rpc::Feature id;
- void (*setup)();
+ const char* (*setup)();
};
static thread_t* schedule_call(int call_index, int call_num, uint64 copyout_index, uint64 num_args, uint64* args, uint8* pos, call_props_t call_props);
@@ -410,6 +410,10 @@ static void setup_features(char** enable, int n);
#error "unknown OS"
#endif
+#if !SYZ_HAVE_FEATURES
+static feature_t features[] = {};
+#endif
+
#include "cov_filter.h"
#include "test.h"
@@ -1655,10 +1659,6 @@ bool kcov_comparison_t::operator<(const struct kcov_comparison_t& other) const
}
#endif // if SYZ_EXECUTOR_USES_SHMEM
-#if !SYZ_HAVE_FEATURES
-static feature_t features[] = {};
-#endif
-
void setup_features(char** enable, int n)
{
// This does any one-time setup for the requested features on the machine.
@@ -1684,7 +1684,9 @@ void setup_features(char** enable, int n)
}
for (size_t i = 0; i < sizeof(features) / sizeof(features[0]); i++) {
if (features[i].id == feature) {
- features[i].setup();
+ const char* reason = features[i].setup();
+ if (reason)
+ fail(reason);
return;
}
}