Skip to content

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

Open
flyq wants to merge 1 commit into
mainfrom
liquan/chore/bump-nightly-closure-miscompile
Open

flyq wants to merge 1 commit 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 follows in megaeth-labs/mega-reth#2561.

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).
  • AGENTS.md (and so CLAUDE.md, a symlink to it): the documented toolchain.

No 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.
  • Those three crates still compile on mega-reth develop's nightly-2025-12-20 (cargo +nightly-2025-12-20 check --ignore-rust-version, with default features, --all-features and --no-default-features), so this lands independently of mega-reth#2561.
  • 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 99c6ed29 · updated 2026-11-03T09:17:46+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/41609772022

This branch has not been deployed

No deployments
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.

1 participant