Skip to content

Match enable-only compat flags when Rust is built with ASan - #8924

Merged
danlapid merged 1 commit into
mainfrom
dlapid/rust-compat-date-asan
Nov 25, 2026
Merged

danlapid merged 1 commit into
mainfrom
dlapid/rust-compat-date-asan

Conversation

@danlapid

Copy link
Copy Markdown
Collaborator

With -Zsanitizer=address at opt-level 3, rustc compiles FlagInfo::flags_in_match_order(), inlined into FlagTable::read(), so that first.into_iter().chain(second) yields nothing when first is the enable flag and second is None. FlagTable::slots then has no entry for any of the 54 flags without a disable flag (experimental, python_workers, html_rewriter_treats_esi_include_as_void_tag, ...). With RUST_COMPAT_DATE on, naming any of them fails with "No such compatibility flag".

In such a build:

  • compat-date_test's gates_experimental_flags fails (assertion failed: is_on(&c, "obsolete19")).
  • compatibility-date-legacy-test's "the Rust compiler agrees with the C++ compiler" fails on esiIncludeIsVoidTag.

This builds the iterator from a two-element array instead, which that build compiles correctly. The new maps_every_flag_to_its_slot test checks the whole table against the schema's flags. Without the fix it fails in that build, with 310 of 364 names present and none under a wrong slot.

Tested with an ASan, opt-level 3 build: compat-date_test, compatibility-date-legacy-test, and the @all-autogates test variants pass with the fix.

🤖 Generated with Claude Code

@guybedford
guybedford marked this pull request as ready for review November 25, 2026 23:34
@guybedford
guybedford requested review from a team as code owners November 25, 2026 23:34
@guybedford
guybedford enabled auto-merge (squash) November 25, 2026 23:34

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of 4d114518.

This review, of 2a1fde12

✅ Approved — This rewrite of flags_in_match_order() behaves the same as before and keeps the disable_flag_first order. The new test builds its expected slot map on its own, so it would catch a dropped enable-only flag. No issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

The change only alters how an internal iterator is built; flag lookup behaves the same. It touches no trust boundary, input handling or access control, and the new test is test-only.


📋 Code Quality: ✅ LGTM

[first, second].into_iter().flatten() yields the same pairs in the same order as first.into_iter().chain(second). It also keeps the disable_flag_first ordering that the first-wins insertion in FlagTable::read depends on.

maps_every_flag_to_its_slot builds its expected map straight from enable_flag and disable_flag, with the same first-wins entry semantics, so it does not rely on flags_in_match_order. If an enable-only flag goes missing from slots, the test fails.

The new comment explains why the array form is used and names the test that guards it, which fits the repository's comment guidelines.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: 2a1fde12

With -Zsanitizer=address at opt-level 3, rustc compiled
FlagInfo::flags_in_match_order(), inlined into FlagTable::read(), so
that `first.into_iter().chain(second)` yielded nothing when `first`
was the enable flag and `second` was None. FlagTable::slots then had
no entry for any of the 54 flags without a disable flag, among them
`experimental` and `python_workers`, and with RUST_COMPAT_DATE on,
naming any of them failed with "No such compatibility flag". In such
a build, compat-date_test's gates_experimental_flags fails, as does
compatibility-date-legacy-test's comparison with the C++ compiler.

Build the iterator from a two-element array instead, which that build
compiles correctly. maps_every_flag_to_its_slot checks the whole table
against the schema's flags, and fails in that build without the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@danlapid
danlapid force-pushed the dlapid/rust-compat-date-asan branch from 2a1fde1 to 4d11451 Compare November 25, 2026 23:41

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — This rewrite of flags_in_match_order() behaves the same as before and keeps the disable_flag_first order. The new test builds its expected slot map on its own, so it would catch a dropped enable-only flag. No issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

The change only alters how an internal iterator is built; flag lookup behaves the same. It touches no trust boundary, input handling or access control, and the new test is test-only.


📋 Code Quality: ✅ LGTM

[first, second].into_iter().flatten() yields the same pairs in the same order as first.into_iter().chain(second). It also keeps the disable_flag_first ordering that the first-wins insertion in FlagTable::read depends on.

maps_every_flag_to_its_slot builds its expected map straight from enable_flag and disable_flag, with the same first-wins entry semantics, so it does not rely on flags_in_match_order. If an enable-only flag goes missing from slots, the test fails.

The new comment explains why the array form is used and names the test that guards it, which fits the repository's comment guidelines.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: 4d114518 — same changes as 2a1fde12, so this is that commit's review (no new review was run; line numbers are as of 2a1fde12)

@danlapid
danlapid disabled auto-merge November 25, 2026 23:46
@danlapid
danlapid merged commit 859fc5e into main Nov 25, 2026
21 checks passed
@danlapid
danlapid deleted the dlapid/rust-compat-date-asan branch November 25, 2026 23:47
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