diff --git a/src/deterministic_random.h b/src/deterministic_random.h index cc6de91..a5ab922 100644 --- a/src/deterministic_random.h +++ b/src/deterministic_random.h @@ -42,7 +42,7 @@ class RngChannel; class RngSeed { public: RngSeed(); - RngSeed(uint64_t seed); + explicit RngSeed(uint64_t seed); RngSeed(const RngSeed &rng) = delete; RngSeed(RngSeed &&rng); @@ -58,7 +58,7 @@ class RngSeed { class RngStream { private: - RngStream(uint64_t seed, uint64_t stream); + explicit RngStream(uint64_t seed, uint64_t stream); public: uint64_t uniform_uint64_t(); @@ -81,7 +81,7 @@ static_assert(std::is_trivially_copyable_v); class RngChannel { private: template - RngChannel(uint64_t seed, uint64_t stream, const T &hashable); + explicit RngChannel(uint64_t seed, uint64_t stream, const T &hashable); public: uint64_t uniform_uint64_t(); diff --git a/src/fuzzer.cc b/src/fuzzer.cc index e66b751..4353663 100644 --- a/src/fuzzer.cc +++ b/src/fuzzer.cc @@ -119,7 +119,7 @@ struct FuzzerConfig { return config; } - void log_config(Runtime *runtime, Context ctx) { + void log_config(Runtime *runtime, Context ctx) const { LOG_ONCE(log_fuzz.print() << "Fuzzer Configuration:"); LOG_ONCE(log_fuzz.print() << " config.initial_seed = " << initial_seed); LOG_ONCE(log_fuzz.print() << " config.region_tree_depth = " << region_tree_depth); @@ -139,7 +139,8 @@ struct FuzzerConfig { class OffsetProjection : public ProjectionFunctor { public: - OffsetProjection(uint64_t _offset) : offset(_offset) {} + OffsetProjection() = delete; + explicit OffsetProjection(uint64_t _offset) : offset(_offset) {} bool is_functional(void) const override { return true; } bool is_invertible(void) const override { return false; } unsigned get_depth(void) const override { return 0; } @@ -160,7 +161,8 @@ class OffsetProjection : public ProjectionFunctor { class RandomProjection : public ProjectionFunctor { public: - RandomProjection(RngStream _stream) : stream(_stream) {} + RandomProjection() = delete; + explicit RandomProjection(RngStream _stream) : stream(_stream) {} bool is_functional(void) const override { return true; } bool is_invertible(void) const override { return false; } unsigned get_depth(void) const override { return 0; } @@ -214,7 +216,9 @@ void color_points_task(const Task *task, const std::vector ®i class RegionForest { public: - RegionForest(Runtime *_runtime, Context _ctx, const FuzzerConfig &config, RngSeed &seed) + RegionForest() = delete; + explicit RegionForest(Runtime *_runtime, Context _ctx, const FuzzerConfig &config, + RngSeed &seed) : runtime(_runtime), ctx(_ctx) { ispace = runtime->create_index_space<1>( ctx, @@ -360,7 +364,7 @@ class RegionForest { return true; } - void verify_contents() { + bool verify_contents() { std::vector fields; shadow_inst.get_fields(fields); @@ -404,11 +408,12 @@ class RegionForest { } } if (bad_points > 0) { - log_fuzz.fatal() << "Encountered " << bad_points << " bad region values"; - abort(); + log_fuzz.error() << "Encountered " << bad_points << " bad region values"; } runtime->unmap_region(ctx, inst); + + return bad_points == 0; } private: @@ -528,7 +533,8 @@ const char *redop_name(ReductionOpID redop) { class RequirementBuilder { public: - RequirementBuilder(const FuzzerConfig &_config, RegionForest &_forest) + RequirementBuilder() = delete; + explicit RequirementBuilder(const FuzzerConfig &_config, RegionForest &_forest) : config(_config), forest(_forest) {} void build(RngStream &rng, bool launch_complete, bool requires_projection) { @@ -739,7 +745,8 @@ using FutureCheck = std::pair; class OperationBuilder { public: - OperationBuilder(const FuzzerConfig &_config, RegionForest &_forest) + OperationBuilder() = delete; + explicit OperationBuilder(const FuzzerConfig &_config, RegionForest &_forest) : config(_config), forest(_forest), launch_domain(Rect<1>::make_empty()), @@ -1040,17 +1047,23 @@ void top_level(const Task *task, const std::vector ®ions, Con } } - forest.verify_contents(); + bool region_ok = forest.verify_contents(); + bool future_ok = true; for (FutureCheck &check : futures) { uint64_t result = check.first.get_result(); uint64_t expected = check.second; if (result != expected) { - LOG_ONCE(log_fuzz.fatal() - << "Bad future: " << result << ", expected: " << expected); - abort(); + log_fuzz.error() << "Bad future: " << result << ", expected: " << expected; + future_ok = false; } } + + if (!region_ok) { + Runtime::set_return_code(1); + } else if (!future_ok) { + Runtime::set_return_code(2); + } } static void create_mappers(Machine machine, Runtime *runtime,