Error code 5 is not consistently enforced in shift operators for shifted bits bigger than 256 #3000
Labels
activity: found-by-fuzzing
Do not add! Issues found by fuzzer by previous project.
misc: func-bug
Bugs in FunC compiler
In the following contract:
<<
operator:Calling
getBool1(257)
gives:Error: Unable to execute get method. Got exit_code: 4
(overflow error, meaning that it accepted the value 257 as valid). But interpreter responds with:Cannot evaluate expression to a constant: the number of bits shifted ('257') must be within [0..256] range
.Calling
getBool1(7237005577332262213973186563042994240829374041602535252466099000494570602496)
(i.e.,getBool1(2^252)
) gives:Unable to execute get method. Got exit_code: 5
(range check error). The interpreter response:Cannot evaluate expression to a constant: the number of bits shifted ('7237005577332262213973186563042994240829374041602535252466099000494570602496') must be within [0..256] range
.The above shows that
<<
does not enforce that the shifted bits must be smaller than 257, becausegetBool1(257)
actually attempts to compute2 << 257
producing an overflow. Error code 5 is enforced for very big numbers only.>>
operator:Calling
getBool2(257)
gives:false
. But interpreter responds with:Cannot evaluate expression to a constant: the number of bits shifted ('257') must be within [0..256] range
.Calling
getBool2(7237005577332262213973186563042994240829374041602535252466099000494570602496)
(i.e.,getBool2(2^252)
) gives:Unable to execute get method. Got exit_code: 5
(range check error). The interpreter response:Cannot evaluate expression to a constant: the number of bits shifted ('7237005577332262213973186563042994240829374041602535252466099000494570602496') must be within [0..256] range
.The above shows that
>>
does not enforce that the shifted bits must be smaller than 257, becausegetBool2(257)
returnsfalse
. Error code 5 is enforced for very big numbers only.These examples are different from those in issue #2997 because in the current case, FunC does not simplify the expressions in the Fift code:
The text was updated successfully, but these errors were encountered: