Component
Other (please describe)
Have you ensured that all of these are up to date?
What version of Foundry are you on?
cast 0.2.0 (27956b3 2023-11-30T00:24:55.614692000Z)
What command(s) is the bug in?
cast run tx_hash --debug
Operating System
macOS (Apple Silicon)
Describe the bug
The debugger object won't handle a memory read/ write offset for which the size is bigger than usize::MAX. The bug can be reproduced with the following:
Sets the code to PUSH1 0x01 PUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6 PUSH2 0x0100 LOG1
cast rpc anvil_setCode 0x00000000000000000000000000000000deadbeef 60017ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6610100a1
Set the block gas limit
cast rpc evm_setBlockGasLimit 0x05f5e100
Call 0x00000000000000000000000000000000deadbeef
cast send 0x00000000000000000000000000000000deadbeef --value 1 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --gas-limit 80000000
Once done, run cast run tx_hash --debug. Click on MAJ-G to jump to the latest instruction. You should get panicked at crates/debugger/src/lib.rs:897:65: Uint conversion error: Overflow(256, 18446744073709551606, 18446744073709551615).
This comes from this line shown below:
|
1.. => Some(stack[stack_len - stack_index as usize].to()), |
Which tries to convert Uint256 into a usize. We should convert it safely and display on the debugger that this instruction caused an out of gas due to dynamic gas costs if bigger than usize::MAX.
Component
Other (please describe)
Have you ensured that all of these are up to date?
What version of Foundry are you on?
cast 0.2.0 (27956b3 2023-11-30T00:24:55.614692000Z)
What command(s) is the bug in?
cast run
tx_hash--debugOperating System
macOS (Apple Silicon)
Describe the bug
The debugger object won't handle a memory read/ write offset for which the size is bigger than usize::MAX. The bug can be reproduced with the following:
Sets the code to
PUSH1 0x01 PUSH32 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6 PUSH2 0x0100 LOG1Set the block gas limit
Call 0x00000000000000000000000000000000deadbeef
Once done, run
cast run tx_hash --debug. Click onMAJ-Gto jump to the latest instruction. You should getpanicked at crates/debugger/src/lib.rs:897:65: Uint conversion error: Overflow(256, 18446744073709551606, 18446744073709551615).This comes from this line shown below:
foundry/crates/debugger/src/lib.rs
Line 897 in e26f4d8
Which tries to convert
Uint256into ausize. We should convert it safely and display on the debugger that this instruction caused an out of gas due to dynamic gas costs if bigger than usize::MAX.