-
Notifications
You must be signed in to change notification settings - Fork 788
Open
Description
Description
Using myth analyze
with Solidity programs that use non 256bit integers (e.g. int128
) sometimes results in a Python ValueError: invalid literal for int() with base 16: '0x'
.
How to Reproduce
Program
pragma solidity ^0.8.19;
contract PlaceholderContract {
function yZBfy1RvlSI_i(
bool assert_in4,
int128 assert_in6,
bool assert_in0,
bool assert_in2,
bool assert_in3
) internal returns (bool) {
return ((((assert_in4 ||
(
!(
!(true ||
((assert_in3 || false) || (assert_in0 && assert_in4)))
)
)) &&
(
!(
!((assert_in4 || false) ||
(
!(
!(true ||
((assert_in3 || false) ||
(assert_in0 && (assert_in4 || false))))
)
))
)
)) ||
((((assert_in6 >
(((((int128(616) - int128(52)) + int128(52)) -
(int128(0) + (-int128(0)))) + int128(0)) &
(((int128(616) - int128(52)) + int128(52)) -
(int128(0) + (-int128(0)))))) ||
(((
-(
-(int128(0) -
(((int128(0) - assert_in6) /
((int128(1) + int128(0)) &
(int128(1) + int128(0)))) +
(int128(0) - int128(0))))
)
) == ((int128(616) & int128(616)) - int128(0))) && true)) ||
false) && assert_in2)) &&
(assert_in0 ||
((true ||
(assert_in3 ||
((false && true) || (assert_in0 && assert_in4)))) ||
((((assert_in6 >
((int128(616) - int128(0)) *
(int128(1) - int128(0)))) ||
((int128(0) -
(((int128(0) - (int128(0) + int128(0))) +
((-assert_in6) /
((int128(1) + int128(0)) &
(int128(1) + int128(0))))) -
(int128(48) & int128(0)))) ==
((int128(616) & int128(616)) - int128(0)))) ||
(false || false)) && assert_in2))));
}
function check_entrypoint(
bool assert_in0,
int128 assert_in1,
bool assert_in2,
bool assert_in3,
bool assert_in4,
int128 assert_in5,
int128 assert_in6
) public {
unchecked {
bool assert_out1 = ((((assert_in4 && assert_in4) && assert_in0) ||
((true || assert_in3) || (assert_in0 && assert_in4))) ||
(((assert_in3 && false) || (assert_in6 >= int128(616))) &&
(assert_in2 && (assert_in2 || true))));
bool assert_out2 = ((((assert_in4 ||
(
!(
!(true ||
((assert_in3 || false) ||
(assert_in0 && assert_in4)))
)
)) ||
((((assert_in6 >
(((((int128(616) - int128(52)) - int128(50)) + int128(50)) +
int128(52)) - ((-int128(0)) + int128(0)))) ||
((int128(616) & int128(616)) ==
(int128(0) -
(
-(int128(0) -
(((int128(0) - assert_in6) /
((int128(1) + int128(0)) & int128(1))) +
(int128(0) - int128(0))))
)))) || false) && assert_in2)) &&
(((!(!(assert_in4 || false))) ||
(
!(
!(true ||
((assert_in3 || false) ||
(assert_in0 && assert_in4)))
)
)) ||
(((((-(-assert_in6)) >
((((int128(616) - int128(52)) + int128(52)) -
int128(0)) - (-int128(0)))) ||
((int128(616) & int128(616)) ==
(int128(0) -
(
-(int128(0) -
(((int128(0) - assert_in6) /
((int128(1) + int128(0)) &
int128(1))) +
(int128(0) - int128(0))))
)))) || (false || false)) && assert_in2))) &&
yZBfy1RvlSI_i(
assert_in4,
assert_in6,
assert_in0,
assert_in2,
assert_in3
));
assert((assert_out1 == assert_out2));
}
}
}
Compile Options
solc --evm-version shanghai --optimize --optimize-runs 1000 --via-ir --bin-runtime
Mythril Call
$ myth analyze -c <bytecode>
mythril.interfaces.cli [ERROR]: Traceback (most recent call last):
File "/.../.pyenv/versions/3.13.3/lib/python3.13/site-packages/mythril/interfaces/cli.py", line 975, in parse_args_and_execute
address = load_code(disassembler, args)
File "/.../.pyenv/versions/3.13.3/lib/python3.13/site-packages/mythril/interfaces/cli.py", line 711, in load_code
address, _ = disassembler.load_from_bytecode(code, args.bin_runtime)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/.../.pyenv/versions/3.13.3/lib/python3.13/site-packages/mythril/mythril/mythril_disassembler.py", line 126, in load_from_bytecode
EVMContract(
~~~~~~~~~~~^
creation_code=code,
^^^^^^^^^^^^^^^^^^^
name="MAIN",
^^^^^^^^^^^^
enable_online_lookup=self.enable_online_lookup,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/.../.pyenv/versions/3.13.3/lib/python3.13/site-packages/mythril/ethereum/evmcontract.py", line 39, in __init__
self.creation_disassembly = Disassembly(
~~~~~~~~~~~^
creation_code, enable_online_lookup=enable_online_lookup
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/.../.pyenv/versions/3.13.3/lib/python3.13/site-packages/mythril/disassembler/disassembly.py", line 34, in __init__
self.assign_bytecode(bytecode=code)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/.../.pyenv/versions/3.13.3/lib/python3.13/site-packages/mythril/disassembler/disassembly.py", line 48, in assign_bytecode
function_hash, jump_target, function_name = get_function_info(
~~~~~~~~~~~~~~~~~^
index, self.instruction_list, signatures
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/.../.pyenv/versions/3.13.3/lib/python3.13/site-packages/mythril/disassembler/disassembly.py", line 110, in get_function_info
entry_point = int(offset, 16)
ValueError: invalid literal for int() with base 16: '0x'
$
Expected behavior
The analysis was completed successfully. No issues were detected.
Environment
- Mythril version: v0.24.8
- Solidity compiler and version: 0.8.29+commit.ab55807c.Darwin.appleclang
- Python version: Python 3.13.3
- OS and Version: macOS 15.5
However this is also reproducible on linux x86-64 with the same Solidity compiler and Mythril versions.
Additional Environment or Context
Bytecode for reference https://gist.github.com/sbauer00/1f4ecb72198a97d58e4c8c80a51f4ceb
Metadata
Metadata
Assignees
Labels
No labels