Skip to content

chore: upgrade Rust nightly to fix closure miscompilation - #242

Merged
flyq merged 3 commits into
mainfrom
liquan/chore/bump-nightly-closure-miscompile
Nov 13, 2026
Merged

flyq merged 3 commits into
mainfrom
liquan/chore/bump-nightly-closure-miscompile

Conversation

@flyq

@flyq flyq commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Move the pinned compiler from nightly-2026-02-03 to nightly-2026-04-23, the first nightly with the fix for a closure-call code-generation bug (rust-lang/rust#155241, fixed by rust-lang/rust#155343).
mega-evm moved to the same nightly in megaeth-labs/mega-evm#411, and mega-reth followed in megaeth-labs/mega-reth#2561 (merged 2026-11-13).

Why

With an affected compiler, a by-value argument larger than two words (a Vec, say) passed to a closure call can be the caller's own memory instead of a temporary copy, so the callee mutates it in place.
In optimized builds this shows as silently wrong values on 1.77–1.90 and as a double free from 1.91 on.
nightly-2026-02-03 is 1.95.0-nightly, inside that range, and every release binary is built with it, mega-evm included.
mega-evm#411 notes that a downstream build on an affected compiler needs its own pin update.

No impact has been observed: mega-evm replayed mainnet blocks under both compilers with byte-identical results, and mega-reth#2561 did the same through the stateless-core validation path.
A miscompile cannot be ruled out code path by code path, so the fix is the compiler.

Changes

  • rust-toolchain.toml: nightly-2026-02-03 → nightly-2026-04-23 (1.97.0-nightly, LLVM 22.1.2).
  • Cargo.toml / Cargo.lock: mega-evm 7574376 → c671ef0 (chore: bump Rust nightly to fix closure-call miscompilation mega-evm#411), the same rev mega-reth develop pins after megaeth-labs/mega-reth#2561.
    The only file that commit changes is mega-evm's own rust-toolchain.toml, which Cargo ignores for a git dependency, so the compiled mega-evm source is unchanged.
  • AGENTS.md (and so CLAUDE.md, a symlink to it): the documented toolchain.

No Rust source changes: the new nightly brings no rustfmt or Clippy findings in either CI configuration.

Compatibility

  • rust-version stays 1.94.
    mega-reth builds stateless-common, stateless-core and stateless-r2 with its own pinned compiler, and raising it would make mega-reth's 1.94.0-nightly refuse them.
  • mega-reth develop is now on the same nightly-2026-04-23 and the same mega-evm rev, so the compiler and the EVM pin agree between the two repos.
    Its pin of these three crates (a365a65) predates this PR and is unaffected.
  • coverage-replayer folds rustc -vV (release, commit hash, LLVM version) into its binary_id, so stores scanned with the old compiler do not carry over; carry the candidate pool across with inspect --dump-pool before the next scan.

Tests

On nightly-2026-04-23:

  • cargo test --workspace: 622 passed, 0 failed, 40 ignored (the endpoint-backed debug-trace-server integration tests), the same as on the old compiler; the test profile is optimized, where the bug shows.
    This includes validate_block_mainnet_fixtures over all 63 mainnet fixture blocks and replays_mainnet_fixtures_with_header_sanity.
  • cargo fmt --all --check, cargo sort --check, and both CI Clippy configurations: clean.

🤖 Generated with Claude Code

Move the pinned compiler from nightly-2026-02-03 to nightly-2026-04-23, the
first nightly with the fix for a closure-call code-generation bug
(rust-lang/rust#155241, fixed by rust-lang/rust#155343).
With an affected compiler, a by-value argument larger than two words (a
`Vec`, say) passed to a closure call can alias the caller's memory instead
of a temporary copy, so the callee mutates it in place: silently wrong
values on 1.77-1.90, a double free from 1.91 on, in optimized builds.
nightly-2026-02-03 (1.95.0-nightly) is in that range, and every release
binary, mega-evm included, is built with it.

mega-evm moved to the same nightly in megaeth-labs/mega-evm#411 and mega-reth
follows in megaeth-labs/mega-reth#2561; mega-evm notes that a downstream
build on an affected compiler needs its own pin update.

No source changes: the new nightly brings no rustfmt or clippy findings in
either CI configuration.
rust-version stays 1.94, since mega-reth builds the shared crates with its own
pinned compiler, and they still compile on mega-reth develop's
nightly-2025-12-20.
coverage-replayer folds the compiler into its binary_id, so stores scanned
with the old compiler do not carry over.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mega-maxwell

mega-maxwell Bot commented Nov 3, 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 did not finish

Attempted head 511768ee · updated 2026-11-13T07:37:05+00:00

This round did not publish: MODEL_ACTION_FAILED: The Claude review retry action failed.. Anything listed below is from the last round that did. Workflow run: https://github.com/megaeth-labs/stateless-validator/actions/runs/43386965585

Picks up megaeth-labs/mega-evm#411, which bumps its Rust nightly to fix the same closure-call miscompilation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@vincent-k2026 vincent-k2026 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. The conflict is only in Cargo.toml (keep both the mega-evm and salt revs); please resolve it by merging main. It is worth mentioning the mega-evm rev bump in the body.

…htly-closure-miscompile

Keeps mega-evm at c671ef0 and takes main's salt abf47a4.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@flyq
flyq merged commit c46a541 into main Nov 13, 2026
16 of 17 checks passed
@flyq
flyq deleted the liquan/chore/bump-nightly-closure-miscompile branch November 13, 2026 07:58
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.

3 participants