Skip to content

chore: bump Rust nightly to fix closure-call miscompilation - #411

Merged
RealiCZ merged 1 commit into
mainfrom
cz/chore/rust-toolchain-fix
Oct 28, 2026
Merged

RealiCZ merged 1 commit into
mainfrom
cz/chore/rust-toolchain-fix

Conversation

@RealiCZ

@RealiCZ RealiCZ commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Moves the pinned Rust nightly from nightly-2026-04-14 to nightly-2026-04-23, the first nightly with the fix for a code-generation bug in closure calls (rust-lang/rust#155241, fixed by rust-lang/rust#155343). No source changes: the new nightly brings no new clippy or rustfmt findings, so rust-toolchain.toml is the only file that changes. No execution result changes; the evidence is below.

Why

With the old pin, a by-value argument passed by pointer to a closure call (a type over two words, such as a Vec) can be the caller's own memory instead of a temporary copy, and the callee can mutate it in place. From Rust 1.91 this shows as a double free, and on 1.77–1.90 as silently wrong values. Four tests in crates/mega-evm/tests/rex6/ (the volatile-guard run(first, second) bytecode-builder helpers) abort in an optimized build on the old pin, and pass on the new one. The repository keeps a nightly because of Miri, rust-src and its nightly-only rustfmt options.

The same results under both compilers

  • Replayed recorded mainnet blocks with mega-evme built by each compiler: 200 consecutive Rex6 blocks (5,201 transactions) and 31 blocks across every spec (799 transactions). Every receipt and block check matches the chain on both, and the two outputs are byte-identical.
  • state-test --json-outcome over the execution-spec state tests: all 48,938 outcomes are byte-identical between the two compilers, the existing baseline failures included.

Verification

  • cargo fmt --all --check; clippy with CI's flags and -D warnings; cargo sort --check; the no_std check on riscv64imac-unknown-none-elf.
  • RUSTFLAGS="-D warnings" cargo test --workspace --release --locked passes, including the four rex6 tests that abort on the old pin; the debug cargo test --workspace and the mega-evme tests pass.
  • Every CI workflow takes the compiler from rust-toolchain.toml; no other place names the old date.

Notes

  • CodSpeed: a compiler change moves instruction counts without any source change, so this PR's CodSpeed report reflects code generation only, and later comparisons should have both sides on the new compiler.
  • Consumers build this crate with their own workspace's compiler; a downstream build still on an affected compiler needs its own pin update.

Use nightly-2026-04-23, the first nightly with rust-lang/rust#155343, which fixes the indirect closure argument miscompilation in rust-lang/rust#155241.
@RealiCZ
RealiCZ requested review from Troublor and flyq as code owners October 26, 2026 03:49
@RealiCZ RealiCZ added spec:unchanged No change to any `mega-evm`'s behavior comp:misc Changes to the miscellaneous part of this repo labels Oct 26, 2026
@RealiCZ RealiCZ added the api:unchanged No change to the public interface or API label Oct 26, 2026
@mega-maxwell

mega-maxwell Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Claude review status

Living comment — rewritten in place. The review workflow keeps this single comment up to date instead of posting a new one each round, so it always describes the latest reviewed commit and the earlier text is intentionally gone. No reply is needed here; reply to a finding in its own review thread, and answer an open question in a reply on this PR. The next review round reconciles your answer.

✅ Review clean

Last reviewed: head 66151a1d · updated 2026-10-26T03:51:05+00:00

New this round: 0 finding(s), 0 question(s) · Resolved this round: 0 · Open questions: 0

@github-actions

Copy link
Copy Markdown

🧬 Mutation testing — ✅ PASS

Nothing to test — no mutants were generated on the changed lines.

@github-actions

Copy link
Copy Markdown

🧬 Mutation testing

No results at target/mutants/mutants.out — nothing was mutated (e.g. no mutatable changes).

@codspeed

codspeed Bot commented Oct 26, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 5.68%

2 warnings

⚠️ Unable to measure the execution of 16 benchmarks

These benchmarks measured no execution time, so their results are not comparable and count as unchanged. This usually happens when the compiler removes the code under test.

Prevent compiler optimizations

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 358 untouched benchmarks
⏩ 30 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ rex4 2.5 ms 2.4 ms +5.68%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing cz/chore/rust-toolchain-fix (66151a1) with main (821577d)

Open in CodSpeed

Footnotes

  1. 30 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@mega-putin

mega-putin Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Verified on Linux x86_64, independent worktrees, no product-code edits.

origin/main 821577dc (nightly-2026-04-14 / rustc 1.97.0-nightly (17584a181 2026-04-13)):

cargo test -p mega-evm --test rex6 test_extra_cold_balance_costs_its_full_cold_price
  • debug: pass
  • --release: SIGABRT, free(): double free detected in tcache 2 (exit 101)

test_extra_cold_sload_costs_its_full_cold_price passed in both debug and release on this pin.

This PR 66151a1d (nightly-2026-04-23 / rustc 1.97.0-nightly (913e4bea8 2026-04-22)):

Same two filters, debug and --release: all four runs pass. The BALANCE case no longer double-frees.

Note: on current main the assert_one_more_occurrence_costs(first, second) helper is only used by those two rex6 tests; only the BALANCE one aborted here. Did not rerun the full workspace suite or CodSpeed.

@RealiCZ
RealiCZ merged commit c671ef0 into main Oct 28, 2026
52 checks passed
@RealiCZ
RealiCZ deleted the cz/chore/rust-toolchain-fix branch October 28, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api:unchanged No change to the public interface or API comp:misc Changes to the miscellaneous part of this repo spec:unchanged No change to any `mega-evm`'s behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants