Skip to content

fix(runtime): harden trap jumps and bound safe LEB reads#477

Open
starwarfan wants to merge 1 commit into
DTVMStack:mainfrom
starwarfan:c04-runtime-trap-leb-hardening
Open

fix(runtime): harden trap jumps and bound safe LEB reads#477
starwarfan wants to merge 1 commit into
DTVMStack:mainfrom
starwarfan:c04-runtime-trap-leb-hardening

Conversation

@starwarfan
Copy link
Copy Markdown
Contributor

Switch trap recovery to sigsetjmp/siglongjmp so signal masks are restored after CPU traps, and add explicit end-bounded decoding in readSafeLEBNumber with call-site updates across bytecode visitors and interpreter paths.

Made-with: Cursor

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

2. What is the scope of this PR (e.g. component or file name):

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

  • Affects user behaviors
  • Contains CI/CD configuration changes
  • Contains documentation changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

6. Release note

None

Switch trap recovery to sigsetjmp/siglongjmp so signal masks are restored after CPU traps, and add explicit end-bounded decoding in readSafeLEBNumber with call-site updates across bytecode visitors and interpreter paths.

Made-with: Cursor
@github-actions
Copy link
Copy Markdown

⚡ Performance Regression Check Results

✅ Performance Check Passed (interpreter)

Performance Benchmark Results (threshold: 25%)

Benchmark Baseline (us) Current (us) Change Status
total/main/blake2b_huff/8415nulls 1.57 1.53 -2.4% PASS
total/main/blake2b_huff/empty 0.03 0.02 -2.9% PASS
total/main/blake2b_shifts/8415nulls 12.00 11.99 -0.1% PASS
total/main/sha1_divs/5311 5.21 5.21 +0.0% PASS
total/main/sha1_divs/empty 0.06 0.07 +0.8% PASS
total/main/sha1_shifts/5311 3.11 2.95 -5.2% PASS
total/main/sha1_shifts/empty 0.04 0.04 -4.4% PASS
total/main/snailtracer/benchmark 54.79 54.44 -0.6% PASS
total/main/structarray_alloc/nfts_rank 1.08 1.03 -4.7% PASS
total/main/swap_math/insufficient_liquidity 0.00 0.00 -0.7% PASS
total/main/swap_math/received 0.00 0.00 -1.1% PASS
total/main/swap_math/spent 0.00 0.00 -0.6% PASS
total/main/weierstrudel/1 0.28 0.28 -1.2% PASS
total/main/weierstrudel/15 3.11 3.11 -0.2% PASS
total/micro/JUMPDEST_n0/empty 1.47 1.96 +33.1% PASS
total/micro/jump_around/empty 0.09 0.09 +3.1% PASS
total/micro/loop_with_many_jumpdests/empty 29.84 22.47 -24.7% PASS
total/micro/memory_grow_mload/by1 0.10 0.10 -7.3% PASS
total/micro/memory_grow_mload/by16 0.11 0.10 -6.3% PASS
total/micro/memory_grow_mload/by32 0.12 0.12 -2.9% PASS
total/micro/memory_grow_mload/nogrow 0.10 0.10 -3.5% PASS
total/micro/memory_grow_mstore/by1 0.10 0.10 +7.2% PASS
total/micro/memory_grow_mstore/by16 0.11 0.11 -0.1% PASS
total/micro/memory_grow_mstore/by32 0.12 0.12 +0.1% PASS
total/micro/memory_grow_mstore/nogrow 0.10 0.09 -9.3% PASS
total/micro/signextend/one 0.24 0.24 -0.1% PASS
total/micro/signextend/zero 0.24 0.24 -0.6% PASS
total/synth/ADD/b0 1.95 1.95 -0.2% PASS
total/synth/ADD/b1 1.98 1.98 -0.1% PASS
total/synth/ADDRESS/a0 4.86 4.85 -0.1% PASS
total/synth/ADDRESS/a1 5.42 5.42 +0.0% PASS
total/synth/AND/b0 1.71 1.71 -0.0% PASS
total/synth/AND/b1 1.71 1.72 +0.2% PASS
total/synth/BYTE/b0 6.20 6.21 +0.1% PASS
total/synth/BYTE/b1 4.82 4.81 -0.2% PASS
total/synth/CALLDATASIZE/a0 3.51 3.50 -0.0% PASS
total/synth/CALLDATASIZE/a1 3.92 3.92 +0.2% PASS
total/synth/CALLER/a0 4.82 4.82 -0.0% PASS
total/synth/CALLER/a1 5.37 5.37 +0.0% PASS
total/synth/CALLVALUE/a0 3.75 3.75 -0.0% PASS
total/synth/CALLVALUE/a1 3.75 3.75 -0.0% PASS
total/synth/CODESIZE/a0 4.07 4.08 +0.2% PASS
total/synth/CODESIZE/a1 4.08 4.08 -0.1% PASS
total/synth/DUP1/d0 1.39 1.15 -17.4% PASS
total/synth/DUP1/d1 1.39 1.39 -0.2% PASS
total/synth/DUP10/d0 1.39 1.39 -0.2% PASS
total/synth/DUP10/d1 1.40 1.39 -0.2% PASS
total/synth/DUP11/d0 1.39 1.39 -0.2% PASS
total/synth/DUP11/d1 1.39 1.39 +0.0% PASS
total/synth/DUP12/d0 1.15 1.15 -0.0% PASS
total/synth/DUP12/d1 1.39 1.40 +0.2% PASS
total/synth/DUP13/d0 1.39 1.15 -17.6% PASS
total/synth/DUP13/d1 1.39 1.39 +0.0% PASS
total/synth/DUP14/d0 1.39 1.39 +0.2% PASS
total/synth/DUP14/d1 1.39 1.15 -17.1% PASS
total/synth/DUP15/d0 1.16 1.39 +20.5% PASS
total/synth/DUP15/d1 1.39 1.18 -15.4% PASS
total/synth/DUP16/d0 1.39 1.15 -17.7% PASS
total/synth/DUP16/d1 1.39 1.39 +0.1% PASS
total/synth/DUP2/d0 1.39 1.33 -4.1% PASS
total/synth/DUP2/d1 1.39 1.24 -10.7% PASS
total/synth/DUP3/d0 1.39 1.39 -0.0% PASS
total/synth/DUP3/d1 1.39 1.16 -17.0% PASS
total/synth/DUP4/d0 1.39 1.15 -17.4% PASS
total/synth/DUP4/d1 1.39 1.15 -17.3% PASS
total/synth/DUP5/d0 1.39 1.39 -0.2% PASS
total/synth/DUP5/d1 1.39 1.39 +0.0% PASS
total/synth/DUP6/d0 1.39 1.22 -12.8% PASS
total/synth/DUP6/d1 1.39 1.39 +0.0% PASS
total/synth/DUP7/d0 1.39 1.39 -0.2% PASS
total/synth/DUP7/d1 1.39 1.39 -0.1% PASS
total/synth/DUP8/d0 1.39 1.26 -9.3% PASS
total/synth/DUP8/d1 1.39 1.39 -0.0% PASS
total/synth/DUP9/d0 1.39 1.39 +0.0% PASS
total/synth/DUP9/d1 1.39 1.39 +0.0% PASS
total/synth/EQ/b0 2.73 2.73 -0.0% PASS
total/synth/EQ/b1 1.40 1.40 +0.1% PASS
total/synth/GAS/a0 3.83 3.83 +0.0% PASS
total/synth/GAS/a1 3.83 3.84 +0.1% PASS
total/synth/GT/b0 2.62 2.62 -0.1% PASS
total/synth/GT/b1 1.64 1.64 +0.1% PASS
total/synth/ISZERO/u0 1.47 1.47 -0.1% PASS
total/synth/JUMPDEST/n0 1.87 1.47 -21.1% PASS
total/synth/LT/b0 2.58 2.58 +0.0% PASS
total/synth/LT/b1 1.64 1.64 +0.1% PASS
total/synth/MSIZE/a0 4.23 4.23 +0.0% PASS
total/synth/MSIZE/a1 4.83 4.83 +0.0% PASS
total/synth/MUL/b0 5.32 5.31 -0.0% PASS
total/synth/MUL/b1 5.30 5.30 +0.0% PASS
total/synth/NOT/u0 1.84 1.83 -0.1% PASS
total/synth/OR/b0 1.65 1.65 +0.0% PASS
total/synth/OR/b1 1.71 1.71 +0.1% PASS
total/synth/PC/a0 3.67 3.66 -0.1% PASS
total/synth/PC/a1 3.67 3.67 +0.0% PASS
total/synth/PUSH1/p0 1.23 1.23 -0.1% PASS
total/synth/PUSH1/p1 1.42 1.41 -0.2% PASS
total/synth/PUSH10/p0 1.31 1.31 +0.1% PASS
total/synth/PUSH10/p1 1.46 1.45 -0.6% PASS
total/synth/PUSH11/p0 1.27 1.31 +3.4% PASS
total/synth/PUSH11/p1 1.48 1.43 -2.8% PASS
total/synth/PUSH12/p0 1.23 1.31 +6.4% PASS
total/synth/PUSH12/p1 1.43 1.46 +2.1% PASS
total/synth/PUSH13/p0 1.23 1.23 +0.1% PASS
total/synth/PUSH13/p1 1.44 1.48 +3.1% PASS
total/synth/PUSH14/p0 1.33 1.24 -6.7% PASS
total/synth/PUSH14/p1 1.46 1.47 +0.3% PASS
total/synth/PUSH15/p0 1.31 1.23 -6.2% PASS
total/synth/PUSH15/p1 1.50 1.60 +6.2% PASS
total/synth/PUSH16/p0 1.23 1.31 +6.6% PASS
total/synth/PUSH16/p1 1.45 1.46 +0.8% PASS
total/synth/PUSH17/p0 1.31 1.07 -18.4% PASS
total/synth/PUSH17/p1 1.42 1.43 +0.7% PASS
total/synth/PUSH18/p0 1.23 1.31 +6.6% PASS
total/synth/PUSH18/p1 1.45 1.45 +0.2% PASS
total/synth/PUSH19/p0 1.23 1.31 +6.6% PASS
total/synth/PUSH19/p1 1.42 1.43 +0.6% PASS
total/synth/PUSH2/p0 1.31 1.24 -5.7% PASS
total/synth/PUSH2/p1 1.42 1.42 +0.1% PASS
total/synth/PUSH20/p0 1.31 1.31 +0.0% PASS
total/synth/PUSH20/p1 1.47 1.46 -0.4% PASS
total/synth/PUSH21/p0 1.31 1.31 +0.0% PASS
total/synth/PUSH21/p1 1.42 1.43 +0.4% PASS
total/synth/PUSH22/p0 1.31 1.31 +0.1% PASS
total/synth/PUSH22/p1 1.43 1.45 +1.0% PASS
total/synth/PUSH23/p0 1.31 1.31 -0.0% PASS
total/synth/PUSH23/p1 1.43 1.44 +0.6% PASS
total/synth/PUSH24/p0 1.23 1.23 +0.2% PASS
total/synth/PUSH24/p1 1.43 1.45 +1.8% PASS
total/synth/PUSH25/p0 1.31 1.31 +0.0% PASS
total/synth/PUSH25/p1 1.42 1.42 +0.2% PASS
total/synth/PUSH26/p0 1.31 1.07 -18.4% PASS
total/synth/PUSH26/p1 1.44 1.46 +1.4% PASS
total/synth/PUSH27/p0 1.31 1.31 +0.0% PASS
total/synth/PUSH27/p1 1.42 1.43 +0.4% PASS
total/synth/PUSH28/p0 1.23 1.31 +6.6% PASS
total/synth/PUSH28/p1 1.42 1.43 +0.5% PASS
total/synth/PUSH29/p0 1.23 1.31 +6.6% PASS
total/synth/PUSH29/p1 1.42 1.47 +3.6% PASS
total/synth/PUSH3/p0 1.31 1.23 -6.2% PASS
total/synth/PUSH3/p1 1.42 1.42 +0.1% PASS
total/synth/PUSH30/p0 1.31 1.32 +0.2% PASS
total/synth/PUSH30/p1 1.42 1.43 +1.0% PASS
total/synth/PUSH31/p0 1.31 1.31 -0.0% PASS
total/synth/PUSH31/p1 1.56 1.55 -0.5% PASS
total/synth/PUSH32/p0 1.31 1.31 -0.1% PASS
total/synth/PUSH32/p1 1.43 1.45 +1.4% PASS
total/synth/PUSH4/p0 1.23 1.31 +6.6% PASS
total/synth/PUSH4/p1 1.45 1.46 +0.1% PASS
total/synth/PUSH5/p0 1.23 1.31 +6.6% PASS
total/synth/PUSH5/p1 1.46 1.46 +0.2% PASS
total/synth/PUSH6/p0 1.23 1.31 +6.6% PASS
total/synth/PUSH6/p1 1.45 1.46 +0.2% PASS
total/synth/PUSH7/p0 1.31 1.31 +0.1% PASS
total/synth/PUSH7/p1 1.46 1.22 -16.2% PASS
total/synth/PUSH8/p0 1.23 1.31 +6.7% PASS
total/synth/PUSH8/p1 1.46 1.46 -0.3% PASS
total/synth/PUSH9/p0 1.31 1.25 -5.0% PASS
total/synth/PUSH9/p1 1.43 1.47 +2.9% PASS
total/synth/RETURNDATASIZE/a0 4.16 4.17 +0.3% PASS
total/synth/RETURNDATASIZE/a1 4.16 4.16 +0.0% PASS
total/synth/SAR/b0 3.91 3.80 -2.9% PASS
total/synth/SAR/b1 4.29 4.31 +0.4% PASS
total/synth/SGT/b0 2.59 2.59 +0.0% PASS
total/synth/SGT/b1 1.64 1.64 +0.0% PASS
total/synth/SHL/b0 3.03 3.03 +0.0% PASS
total/synth/SHL/b1 1.68 1.68 +0.2% PASS
total/synth/SHR/b0 2.95 2.95 +0.0% PASS
total/synth/SHR/b1 1.68 1.68 -0.1% PASS
total/synth/SIGNEXTEND/b0 3.75 3.75 -0.0% PASS
total/synth/SIGNEXTEND/b1 3.79 3.79 +0.0% PASS
total/synth/SLT/b0 2.59 2.59 -0.0% PASS
total/synth/SLT/b1 1.64 1.64 -0.0% PASS
total/synth/SUB/b0 1.99 1.97 -0.9% PASS
total/synth/SUB/b1 2.00 1.99 -0.2% PASS
total/synth/SWAP1/s0 1.49 1.49 -0.0% PASS
total/synth/SWAP10/s0 1.51 1.52 +0.5% PASS
total/synth/SWAP11/s0 1.51 1.52 +0.6% PASS
total/synth/SWAP12/s0 1.51 1.52 +0.7% PASS
total/synth/SWAP13/s0 1.51 1.52 +0.9% PASS
total/synth/SWAP14/s0 1.52 1.53 +0.5% PASS
total/synth/SWAP15/s0 1.52 1.53 +0.4% PASS
total/synth/SWAP16/s0 1.52 1.53 +0.5% PASS
total/synth/SWAP2/s0 1.49 1.49 +0.2% PASS
total/synth/SWAP3/s0 1.50 1.50 +0.1% PASS
total/synth/SWAP4/s0 1.49 1.50 +0.5% PASS
total/synth/SWAP5/s0 1.50 1.50 +0.3% PASS
total/synth/SWAP6/s0 1.50 1.51 +0.2% PASS
total/synth/SWAP7/s0 1.50 1.51 +0.6% PASS
total/synth/SWAP8/s0 1.51 1.52 +0.6% PASS
total/synth/SWAP9/s0 1.51 1.53 +1.3% PASS
total/synth/XOR/b0 1.55 1.55 -0.0% PASS
total/synth/XOR/b1 1.55 1.55 -0.0% PASS
total/synth/loop_v1 4.39 4.38 -0.1% PASS
total/synth/loop_v2 4.38 4.37 -0.1% PASS

Summary: 194 benchmarks, 0 regressions


✅ Performance Check Passed (multipass)

Performance Benchmark Results (threshold: 25%)

Benchmark Baseline (us) Current (us) Change Status
total/main/blake2b_huff/8415nulls 0.84 0.85 +1.2% PASS
total/main/blake2b_huff/empty 0.01 0.01 +4.5% PASS
total/main/blake2b_shifts/8415nulls 4.52 4.49 -0.5% PASS
total/main/sha1_divs/5311 0.59 0.59 -0.3% PASS
total/main/sha1_divs/empty 0.01 0.01 +4.3% PASS
total/main/sha1_shifts/5311 0.55 0.55 -0.2% PASS
total/main/sha1_shifts/empty 0.01 0.01 +4.2% PASS
total/main/snailtracer/benchmark 31.42 31.70 +0.9% PASS
total/main/structarray_alloc/nfts_rank 0.30 0.29 -1.8% PASS
total/main/swap_math/insufficient_liquidity 0.00 0.00 +17.8% PASS
total/main/swap_math/received 0.00 0.00 +13.2% PASS
total/main/swap_math/spent 0.00 0.00 +13.3% PASS
total/main/weierstrudel/1 0.24 0.24 +0.1% PASS
total/main/weierstrudel/15 2.59 2.59 +0.0% PASS
total/micro/JUMPDEST_n0/empty 0.00 0.00 +22.4% PASS
total/micro/jump_around/empty 0.05 0.05 -2.3% PASS
total/micro/loop_with_many_jumpdests/empty 0.00 0.00 +11.1% PASS
total/micro/memory_grow_mload/by1 0.01 0.01 +4.2% PASS
total/micro/memory_grow_mload/by16 0.01 0.01 +3.8% PASS
total/micro/memory_grow_mload/by32 0.01 0.01 +3.4% PASS
total/micro/memory_grow_mload/nogrow 0.01 0.01 +5.2% PASS
total/micro/memory_grow_mstore/by1 0.01 0.01 +5.1% PASS
total/micro/memory_grow_mstore/by16 0.01 0.02 +4.7% PASS
total/micro/memory_grow_mstore/by32 0.02 0.02 +3.8% PASS
total/micro/memory_grow_mstore/nogrow 0.01 0.01 +4.4% PASS
total/micro/signextend/one 0.07 0.07 +1.4% PASS
total/micro/signextend/zero 0.07 0.07 +2.0% PASS
total/synth/ADD/b0 0.00 0.00 +7.5% PASS
total/synth/ADD/b1 0.00 0.00 +8.1% PASS
total/synth/ADDRESS/a0 0.15 0.15 +0.3% PASS
total/synth/ADDRESS/a1 0.15 0.15 +0.2% PASS
total/synth/AND/b0 0.00 0.00 +7.5% PASS
total/synth/AND/b1 0.00 0.00 +8.1% PASS
total/synth/BYTE/b0 0.00 0.00 +7.6% PASS
total/synth/BYTE/b1 0.00 0.00 +8.0% PASS
total/synth/CALLDATASIZE/a0 0.07 0.07 +0.5% PASS
total/synth/CALLDATASIZE/a1 0.07 0.07 +0.6% PASS
total/synth/CALLER/a0 0.18 0.18 -0.1% PASS
total/synth/CALLER/a1 0.18 0.18 +0.2% PASS
total/synth/CALLVALUE/a0 0.26 0.27 +0.8% PASS
total/synth/CALLVALUE/a1 0.26 0.27 +0.7% PASS
total/synth/CODESIZE/a0 0.07 0.07 +0.5% PASS
total/synth/CODESIZE/a1 0.07 0.07 +0.5% PASS
total/synth/DUP1/d0 0.00 0.00 +7.6% PASS
total/synth/DUP1/d1 0.00 0.00 +8.1% PASS
total/synth/DUP10/d0 0.00 0.00 +7.4% PASS
total/synth/DUP10/d1 0.00 0.00 +8.3% PASS
total/synth/DUP11/d0 0.00 0.00 +7.8% PASS
total/synth/DUP11/d1 0.00 0.00 +8.1% PASS
total/synth/DUP12/d0 0.00 0.00 +7.8% PASS
total/synth/DUP12/d1 0.00 0.00 +8.1% PASS
total/synth/DUP13/d0 0.00 0.00 +7.6% PASS
total/synth/DUP13/d1 0.00 0.00 +8.1% PASS
total/synth/DUP14/d0 0.00 0.00 +7.8% PASS
total/synth/DUP14/d1 0.00 0.00 +8.3% PASS
total/synth/DUP15/d0 0.00 0.00 +8.4% PASS
total/synth/DUP15/d1 0.00 0.00 +8.0% PASS
total/synth/DUP16/d0 0.00 0.00 +7.7% PASS
total/synth/DUP16/d1 0.00 0.00 +8.3% PASS
total/synth/DUP2/d0 0.00 0.00 +7.6% PASS
total/synth/DUP2/d1 0.00 0.00 +7.8% PASS
total/synth/DUP3/d0 0.00 0.00 +8.0% PASS
total/synth/DUP3/d1 0.00 0.00 +7.9% PASS
total/synth/DUP4/d0 0.00 0.00 +7.8% PASS
total/synth/DUP4/d1 0.00 0.00 +8.2% PASS
total/synth/DUP5/d0 0.00 0.00 +7.5% PASS
total/synth/DUP5/d1 0.00 0.00 +7.9% PASS
total/synth/DUP6/d0 0.00 0.00 +7.6% PASS
total/synth/DUP6/d1 0.00 0.00 +8.0% PASS
total/synth/DUP7/d0 0.00 0.00 +7.6% PASS
total/synth/DUP7/d1 0.00 0.00 +8.2% PASS
total/synth/DUP8/d0 0.00 0.00 +7.8% PASS
total/synth/DUP8/d1 0.00 0.00 +8.3% PASS
total/synth/DUP9/d0 0.00 0.00 +7.8% PASS
total/synth/DUP9/d1 0.00 0.00 +8.0% PASS
total/synth/EQ/b0 0.00 0.00 +7.5% PASS
total/synth/EQ/b1 0.00 0.00 +8.1% PASS
total/synth/GAS/a0 1.10 0.77 -30.7% PASS
total/synth/GAS/a1 1.10 0.77 -30.7% PASS
total/synth/GT/b0 0.00 0.00 +7.2% PASS
total/synth/GT/b1 0.00 0.00 +8.2% PASS
total/synth/ISZERO/u0 0.00 0.00 +8.4% PASS
total/synth/JUMPDEST/n0 0.00 0.00 -11.6% PASS
total/synth/LT/b0 0.00 0.00 +7.6% PASS
total/synth/LT/b1 0.00 0.00 +7.9% PASS
total/synth/MSIZE/a0 0.00 0.00 +7.6% PASS
total/synth/MSIZE/a1 0.00 0.00 +8.2% PASS
total/synth/MUL/b0 0.00 0.00 +7.7% PASS
total/synth/MUL/b1 0.00 0.00 +7.9% PASS
total/synth/NOT/u0 0.00 0.00 +7.8% PASS
total/synth/OR/b0 0.00 0.00 +7.6% PASS
total/synth/OR/b1 0.00 0.00 +8.0% PASS
total/synth/PC/a0 0.00 0.00 +7.7% PASS
total/synth/PC/a1 0.00 0.00 +8.0% PASS
total/synth/PUSH1/p0 0.00 0.00 +8.1% PASS
total/synth/PUSH1/p1 0.00 0.00 +8.1% PASS
total/synth/PUSH10/p0 0.00 0.00 +7.6% PASS
total/synth/PUSH10/p1 0.00 0.00 +8.2% PASS
total/synth/PUSH11/p0 0.00 0.00 +7.6% PASS
total/synth/PUSH11/p1 0.00 0.00 +8.5% PASS
total/synth/PUSH12/p0 0.00 0.00 +7.6% PASS
total/synth/PUSH12/p1 0.00 0.00 +8.0% PASS
total/synth/PUSH13/p0 0.00 0.00 +8.0% PASS
total/synth/PUSH13/p1 0.00 0.00 +8.3% PASS
total/synth/PUSH14/p0 0.00 0.00 +7.7% PASS
total/synth/PUSH14/p1 0.00 0.00 +7.7% PASS
total/synth/PUSH15/p0 0.00 0.00 +7.6% PASS
total/synth/PUSH15/p1 0.00 0.00 +8.1% PASS
total/synth/PUSH16/p0 0.00 0.00 +7.6% PASS
total/synth/PUSH16/p1 0.00 0.00 +7.9% PASS
total/synth/PUSH17/p0 0.00 0.00 +7.7% PASS
total/synth/PUSH17/p1 0.00 0.00 +8.2% PASS
total/synth/PUSH18/p0 0.00 0.00 +8.2% PASS
total/synth/PUSH18/p1 0.00 0.00 +8.0% PASS
total/synth/PUSH19/p0 0.00 0.00 +7.9% PASS
total/synth/PUSH19/p1 0.00 0.00 +7.9% PASS
total/synth/PUSH2/p0 0.00 0.00 +7.7% PASS
total/synth/PUSH2/p1 0.00 0.00 +8.4% PASS
total/synth/PUSH20/p0 0.00 0.00 +7.7% PASS
total/synth/PUSH20/p1 0.00 0.00 +8.1% PASS
total/synth/PUSH21/p0 0.00 0.00 +7.7% PASS
total/synth/PUSH21/p1 0.00 0.00 +8.1% PASS
total/synth/PUSH22/p0 1.31 1.31 +0.0% PASS
total/synth/PUSH22/p1 1.43 1.46 +1.8% PASS
total/synth/PUSH23/p0 1.31 1.31 +0.1% PASS
total/synth/PUSH23/p1 1.46 1.47 +0.7% PASS
total/synth/PUSH24/p0 1.31 1.31 +0.0% PASS
total/synth/PUSH24/p1 1.43 1.43 +0.3% PASS
total/synth/PUSH25/p0 1.31 1.31 +0.1% PASS
total/synth/PUSH25/p1 1.43 1.43 +0.3% PASS
total/synth/PUSH26/p0 1.31 0.99 -24.6% PASS
total/synth/PUSH26/p1 1.47 1.46 -0.6% PASS
total/synth/PUSH27/p0 1.31 1.31 +0.2% PASS
total/synth/PUSH27/p1 1.44 1.43 -0.3% PASS
total/synth/PUSH28/p0 1.31 1.31 +0.1% PASS
total/synth/PUSH28/p1 1.46 1.43 -2.1% PASS
total/synth/PUSH29/p0 1.31 1.31 -0.0% PASS
total/synth/PUSH29/p1 1.46 1.43 -2.0% PASS
total/synth/PUSH3/p0 0.00 0.00 +7.6% PASS
total/synth/PUSH3/p1 0.00 0.00 +8.2% PASS
total/synth/PUSH30/p0 1.32 1.32 -0.3% PASS
total/synth/PUSH30/p1 1.46 1.44 -1.1% PASS
total/synth/PUSH31/p0 1.31 1.31 +0.0% PASS
total/synth/PUSH31/p1 1.57 1.54 -2.2% PASS
total/synth/PUSH32/p0 1.31 1.31 -0.0% PASS
total/synth/PUSH32/p1 1.46 1.45 -0.2% PASS
total/synth/PUSH4/p0 0.00 0.00 +7.6% PASS
total/synth/PUSH4/p1 0.00 0.00 +8.0% PASS
total/synth/PUSH5/p0 0.00 0.00 +8.2% PASS
total/synth/PUSH5/p1 0.00 0.00 +8.1% PASS
total/synth/PUSH6/p0 0.00 0.00 +7.4% PASS
total/synth/PUSH6/p1 0.00 0.00 +8.1% PASS
total/synth/PUSH7/p0 0.00 0.00 +7.7% PASS
total/synth/PUSH7/p1 0.00 0.00 +8.8% PASS
total/synth/PUSH8/p0 0.00 0.00 +7.6% PASS
total/synth/PUSH8/p1 0.00 0.00 +8.4% PASS
total/synth/PUSH9/p0 0.00 0.00 +7.7% PASS
total/synth/PUSH9/p1 0.00 0.00 +8.1% PASS
total/synth/RETURNDATASIZE/a0 0.03 0.03 +1.2% PASS
total/synth/RETURNDATASIZE/a1 0.03 0.03 +1.2% PASS
total/synth/SAR/b0 5.84 5.92 +1.2% PASS
total/synth/SAR/b1 6.63 6.69 +1.0% PASS
total/synth/SGT/b0 0.00 0.00 +8.0% PASS
total/synth/SGT/b1 0.00 0.00 +8.1% PASS
total/synth/SHL/b0 11.87 11.98 +0.9% PASS
total/synth/SHL/b1 11.95 11.97 +0.2% PASS
total/synth/SHR/b0 10.17 10.28 +1.0% PASS
total/synth/SHR/b1 10.36 10.36 +0.1% PASS
total/synth/SIGNEXTEND/b0 0.00 0.00 +7.5% PASS
total/synth/SIGNEXTEND/b1 0.00 0.00 +8.0% PASS
total/synth/SLT/b0 0.00 0.00 +7.7% PASS
total/synth/SLT/b1 0.00 0.00 +8.2% PASS
total/synth/SUB/b0 0.00 0.00 +7.7% PASS
total/synth/SUB/b1 0.00 0.00 +8.5% PASS
total/synth/SWAP1/s0 0.00 0.00 +7.5% PASS
total/synth/SWAP10/s0 0.00 0.00 +7.5% PASS
total/synth/SWAP11/s0 0.00 0.00 +7.4% PASS
total/synth/SWAP12/s0 0.00 0.00 +7.9% PASS
total/synth/SWAP13/s0 0.00 0.00 +7.6% PASS
total/synth/SWAP14/s0 0.00 0.00 +7.5% PASS
total/synth/SWAP15/s0 0.00 0.00 +7.7% PASS
total/synth/SWAP16/s0 0.00 0.00 +8.0% PASS
total/synth/SWAP2/s0 0.00 0.00 +7.8% PASS
total/synth/SWAP3/s0 0.00 0.00 +8.1% PASS
total/synth/SWAP4/s0 0.00 0.00 +7.6% PASS
total/synth/SWAP5/s0 0.00 0.00 +7.7% PASS
total/synth/SWAP6/s0 0.00 0.00 +7.3% PASS
total/synth/SWAP7/s0 0.00 0.00 +7.5% PASS
total/synth/SWAP8/s0 0.00 0.00 +7.5% PASS
total/synth/SWAP9/s0 0.00 0.00 +8.5% PASS
total/synth/XOR/b0 0.00 0.00 +7.7% PASS
total/synth/XOR/b1 0.00 0.00 +8.4% PASS
total/synth/loop_v1 1.16 1.47 +25.9% PASS
total/synth/loop_v2 1.09 1.39 +27.5% PASS

Summary: 194 benchmarks, 0 regressions


Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens runtime trap recovery for JIT execution and makes “safe” LEB decoding explicitly end-bounded to avoid reading past bytecode buffers.

Changes:

  • Switch CPU-trap recovery in JIT paths from setjmp/longjmp to sigsetjmp/siglongjmp (restoring signal masks after traps).
  • Update trap-thread state helpers to store sigjmp_buf and jump via siglongjmp.
  • Change readSafeLEBNumber to accept an explicit End pointer and update bytecode visitor + interpreter call sites accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/utils/wasm.h Updates readSafeLEBNumber to be end-bounded and adds new error signaling for unexpected ends / overly long encodings.
src/runtime/runtime.cpp Switches JIT trap wrappers to sigsetjmp (with signal-mask saving).
src/common/traphandler.h Migrates WASM trap TLS from jmp_buf to sigjmp_buf and uses siglongjmp.
src/common/evm_traphandler.h Migrates EVM trap TLS from jmp_buf to sigjmp_buf and uses siglongjmp.
src/action/interpreter.cpp Updates interpreter immediate decoding call sites to pass an end pointer into readSafeLEBNumber.
src/action/bytecode_visitor.h Updates bytecode visitor immediate decoding and load/store handlers to pass an end pointer into readSafeLEBNumber.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/wasm.h
Comment on lines +92 to +96
while (Ip < End && Count < MaxBytes) {
Byte = *Ip++;
Result |= ((T)(Byte & 0x7f)) << Shift;
Shift += 7;
Count++;
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readSafeLEBNumber() now bounds the read length, but it no longer validates that the decoded value actually fits in T (e.g., u32 values requiring 33+ bits). For unsigned immediates this can wrap/truncate (e.g., 2^32 decodes to 0), which can break correctness and potentially bypass downstream bounds checks (offsets/indices). Consider reusing the same LEBIntTooLarge / signed-top-bits validation logic from readLEBNumber() (and/or accumulating into std::make_unsigned_t and checking the final high bits) so out-of-range encodings are rejected instead of truncated.

Copilot uses AI. Check for mistakes.
Comment thread src/common/traphandler.h
Comment on lines 49 to 52
public:
CallThreadState(runtime::Instance *Inst, jmp_buf *Env, void *FrameAddr,
CallThreadState(runtime::Instance *Inst, sigjmp_buf *Env, void *FrameAddr,
void *PC = nullptr)
: Inst(Inst) {
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header now uses POSIX sigjmp_buf/siglongjmp, but it still only includes . is not required to declare sigjmp_buf/sigsetjmp/siglongjmp in standard C++; relying on it can break builds on some libcs/standard libraries. Prefer including <setjmp.h> (or otherwise ensuring the POSIX declarations are available) under ZEN_ENABLE_CPU_EXCEPTION.

Copilot uses AI. Check for mistakes.
Comment on lines 42 to 45
public:
EVMCallThreadState(runtime::EVMInstance *Inst, jmp_buf *Env, void *FrameAddr,
void *PC = nullptr)
EVMCallThreadState(runtime::EVMInstance *Inst, sigjmp_buf *Env,
void *FrameAddr, void *PC = nullptr)
: Inst(Inst) {
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header now uses POSIX sigjmp_buf/siglongjmp, but it still only includes . is not required to declare sigjmp_buf/sigsetjmp/siglongjmp in standard C++; relying on it can break builds on some libcs/standard libraries. Prefer including <setjmp.h> (or otherwise ensuring the POSIX declarations are available) under ZEN_ENABLE_CPU_EXCEPTION.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants