You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FunC’s optimizer improperly constant-folds expressions like muldiv(x, y, z), muldivc(x, y, z), and muldivr(x, y, z) to zero when either x or y is known to be zero, entirely ignoring the denominator z. According to TVM semantics, these instructions must fail with a division-by-zero error at runtime if z equals zero. The optimizer currently bypasses this check, causing incorrect behavior.
Minimal Example (muldiv):
Input FunC code:
int test(int z) {
return muldiv(0, 1, z);
}
Incorrectly optimized output:
DECLPROC test
test PROC:<{
DROP
0 PUSHINT
}>
The same incorrect behavior occurs with muldivc and muldivr, since all three instructions share the same optimizer logic.
Expected Behavior:
The optimizer should not bypass runtime division-by-zero checks, allowing the TVM to correctly raise errors when the denominator (z) is zero.
Impact:
This bug silently prevents crucial runtime errors, potentially leading to incorrect or unintended behavior in deployed smart contracts.
FunC’s optimizer improperly constant-folds expressions like
muldiv(x, y, z)
,muldivc(x, y, z)
, andmuldivr(x, y, z)
to zero when eitherx
ory
is known to be zero, entirely ignoring the denominatorz
. According to TVM semantics, these instructions must fail with a division-by-zero error at runtime ifz
equals zero. The optimizer currently bypasses this check, causing incorrect behavior.Minimal Example (
muldiv
):Input FunC code:
Incorrectly optimized output:
The same incorrect behavior occurs with
muldivc
andmuldivr
, since all three instructions share the same optimizer logic.Expected Behavior:
The optimizer should not bypass runtime division-by-zero checks, allowing the TVM to correctly raise errors when the denominator (
z
) is zero.Impact:
This bug silently prevents crucial runtime errors, potentially leading to incorrect or unintended behavior in deployed smart contracts.
LLM Fuzzing discovery (see tact-lang/tact#3123)
The text was updated successfully, but these errors were encountered: