From 489b43379e5e1dd5aba84574d17644499a88c398 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Mon, 23 Jun 2025 13:41:38 +0100 Subject: [PATCH 1/2] Avoid binary operations which can overflow when we are in no-dynamic mode --- tooling/ast_fuzzer/src/program/func.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tooling/ast_fuzzer/src/program/func.rs b/tooling/ast_fuzzer/src/program/func.rs index e490fadf977..59fbaa94c70 100644 --- a/tooling/ast_fuzzer/src/program/func.rs +++ b/tooling/ast_fuzzer/src/program/func.rs @@ -726,11 +726,14 @@ impl<'a> FunctionContext<'a> { max_depth: usize, ) -> arbitrary::Result> { // Collect the operations can return the expected type. + // Avoid operations that can fail in no-dynamic mode, otherwise they will be considered non-constant indexes. let ops = BinaryOp::iter() .filter(|op| { types::can_binary_op_return(op, typ) - && (!self.ctx.config.avoid_overflow || !types::can_binary_op_overflow(op)) - && (!self.ctx.config.avoid_err_by_zero || !types::can_binary_op_err_by_zero(op)) + && (!self.ctx.config.avoid_overflow && !self.in_no_dynamic + || !types::can_binary_op_overflow(op)) + && (!self.ctx.config.avoid_err_by_zero && !self.in_no_dynamic + || !types::can_binary_op_err_by_zero(op)) }) .collect::>(); From feba811cdc8591195e42d489e68fd001d9015817 Mon Sep 17 00:00:00 2001 From: Akosh Farkash Date: Mon, 23 Jun 2025 15:47:21 +0100 Subject: [PATCH 2/2] Add paretheses --- tooling/ast_fuzzer/src/program/func.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tooling/ast_fuzzer/src/program/func.rs b/tooling/ast_fuzzer/src/program/func.rs index 59fbaa94c70..ae1678f4a2e 100644 --- a/tooling/ast_fuzzer/src/program/func.rs +++ b/tooling/ast_fuzzer/src/program/func.rs @@ -730,9 +730,9 @@ impl<'a> FunctionContext<'a> { let ops = BinaryOp::iter() .filter(|op| { types::can_binary_op_return(op, typ) - && (!self.ctx.config.avoid_overflow && !self.in_no_dynamic + && (!(self.ctx.config.avoid_overflow || self.in_no_dynamic) || !types::can_binary_op_overflow(op)) - && (!self.ctx.config.avoid_err_by_zero && !self.in_no_dynamic + && (!(self.ctx.config.avoid_err_by_zero || self.in_no_dynamic) || !types::can_binary_op_err_by_zero(op)) }) .collect::>();