Skip to content

fix(runtime): header reads the address-classification audit flags go through the checked probes - #14760

Merged
TheHypnoo merged 3 commits into
PerryTS:mainfrom
raliclo:fix/lint-addrclass
Nov 16, 2026
Merged

TheHypnoo merged 3 commits into
PerryTS:mainfrom
raliclo:fix/lint-addrclass

Conversation

@raliclo

@raliclo raliclo commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

addr_class_inventory.py (lint step "Address-classification audit") has failed on main since 0b2c663 (#14430). That commit gave layout_slot.rs its own copy of array::header::array_gc_header, with a hand-rolled GC_HEADER_SIZE + 0x1000 floor. Such a floor does not reject the fetch, zlib or proxy handle bands, and the ratchet holds layout_slot.rs at 0 handle-floor sites. Later commits added unvalidated as *const/mut GcHeader casts in instrumented-only code (the LIFE census and the snapshot census) and in one test.

This PR removes the debt sites where a checked probe exists. Where the address is the allocator's own record, it adds allowlist entries naming the source. No baseline is raised.

Seen in main's CI run 43639432681 (addr-class RATCHET FAILED). Part of the lint cleanup tracked alongside #14595.

Changes

site introduced by change
layout_slot.rs gc_header (handle-floor + cast) 0b2c663 (#14430), proven: the gate passes at its parent 5c5e568 deleted. The three callers use crate::array::array_gc_header (now pub(crate)), the identical grandfathered probe already counted in array/header.rs, so that file's count is unchanged
array/fill_birth.rs test image 65d502f (#14475) reads the header through array_gc_header
wpfacts_check/life_measure.rs perry_life_birth a44060c try_read_gc_header. A POINTER_TAG payload that is a handle id counts as unborn instead of being dereferenced
wpfacts_check/life.rs full_alive, engine_metadata e6c71cd try_read_gc_header(..).is_some_and(..)
arena/alloc_life.rs birth 1e4db01 / 2d99ce9 the entry guard is is_plausible_heap_addr (was addr < GC_HEADER_SIZE). The claim-outside size read uses try_read_gc_header
arena/alloc_life.rs flush, walk_inline 9afa3f7 / 2d99ce9 allowlist entries. The header is the one the allocator just placed, or one inside an inline burst bounded by [from, to) and each header's size
snap_census/inventory.rs 3c82f01 allowlist entry. Headers come from arena_walk_objects and MALLOC_STATE's tracked list
snap_census/runner.rs holder_words (as *mut) 913a8ae allowlist entry, same justification as the file's existing as *const entry

The "introduced by" column for rows other than layout_slot.rs comes from git log -G on the cast; I probed the gate at commit and parent only for layout_slot.rs. The LIFE and snapshot-census modules compile only under cfg(perry_gc_instruments).

Related issue

Refs #14595, #14604. Main CI run 43639432681.

Test plan

# upstream/main 64257c3159
$ python3 scripts/addr_class_inventory.py
addr-class RATCHET FAILED — ...
  [handle-floor] crates/perry-runtime/src/layout_slot.rs: 1 site(s), baseline allows 0
... plus 10 [gcheader-cast] findings      # exit 1

# this branch
$ python3 scripts/addr_class_inventory.py
Address-classification audit passed (2642 files scanned, 307 allowlisted, 415 known sites held by the ratchet).      # exit 0
$ python3 scripts/addr_class_inventory.py --self-test
addr-class inventory self-tests passed.

# negative control: a new `(arr as usize) < crate::gc::GC_HEADER_SIZE + 0x1000` in layout_slot.rs
  [handle-floor] crates/perry-runtime/src/layout_slot.rs: 1 site(s), baseline allows 0      # exit 1

$ cargo check -p perry-runtime --tests                                                  # ok
$ RUSTFLAGS="--cfg perry_gc_instruments" cargo check -p perry-runtime                   # ok (the instrumented modules)
$ RUST_TEST_THREADS=1 cargo test -p perry-runtime --lib layout_slot    # 14 passed
$ RUST_TEST_THREADS=1 cargo test -p perry-runtime --lib array::        # 520 passed
$ RUST_TEST_THREADS=1 cargo test -p perry-runtime --lib wpfacts_check  # 12 passed

The gate also reports 19 stale (too-high) ratchet counts that main's fixes already earned. This PR leaves them alone; lowering them is a separate --write-baseline change.

  • BASE_SHA=upstream/main scripts/run_lint_gates.sh (macOS arm64): 21 FAIL lines on the branch vs 22 on main 64257c3; the only difference is the gate this PR fixes ([Address-classification audit] python3 scripts/addr_class_inventory.py); no new FAIL.

Checklist

  • I have NOT bumped the workspace version or edited CHANGELOG.md
  • My commits follow the loose feat: / fix: / docs: / chore: prefix convention
  • I've read CONTRIBUTING.md and agree to the Code of Conduct

🤖 Generated with Claude Code

https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p

Summary by CodeRabbit

  • Bug Fixes
    • Allocation tracking now validates claimed addresses and treats unreadable headers as having no known allocation size.
    • Lifetime checks classify pointer-tagged handles without readable object headers as unborn or not alive, and skip sampling them.
    • Array header lookups use the shared header probe across runtime operations.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Array layout and lifetime census paths now use checked GC header lookups. Lifetime checks classify unreadable headers without directly dereferencing the presumed header address. The address-classification allowlist records several instrumented census header reads.

Changes: Checked GC Header Reads

Layer / File(s) Summary
Share array header lookup
crates/perry-runtime/src/array/header.rs, crates/perry-runtime/src/array/mod.rs, crates/perry-runtime/src/layout_slot.rs, crates/perry-runtime/src/array/fill_birth.rs
array_gc_header is available throughout the crate. layout_slot uses it in array operations, and the test helper uses it to obtain a live array head.
Check lifetime header reads
crates/perry-runtime/src/arena/alloc_life.rs, crates/perry-runtime/src/wpfacts_check/life.rs, crates/perry-runtime/src/wpfacts_check/life_measure.rs, scripts/addr_class_allowlist.txt, changelog.d/14760-addrclass-checked-header.md
Lifetime checks and census paths use checked header reads. Unreadable headers return false, contribute zero claim bytes, or count as unborn. The allowlist adds census-read entries, and the changelog describes the related changes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • PerryTS/perry#14604: It identifies the address-classification audit as an unresolved failure; this PR adds checked probes and allowlist entries for that audit.

Suggested reviewers: proggeramlug

Merge Risk: Minimal · up to ba09c

The change swaps unchecked GC header casts for checked reads and adds allowlist entries. It affects only array layout code and instrumented census builds. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the change: header reads in the address-classification audit paths now go through checked probes. The title is specific and matches the changeset. It does not name the lint gate or the…
Description check Passed The description follows the template. It has a Summary that explains the failing audit and the fix. It has a Changes table that lists each file and its change. It has a Related issue section that cite…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: header reads in the address-classification audit paths now go through checked probes. The title is specific and matches the changeset. It does not name the lint gate or the allowlist additions, which is acceptable because the title covers the main change. The title also follows the fix(runtime): prefix convention. Its length (95 characters) is long for a title, but it remains a single sentence.

Full details: Description check

Explanation

The description follows the template. It has a Summary that explains the failing audit and the fix. It has a Changes table that lists each file and its change. It has a Related issue section that cites #14595 and #14604. It has a Test plan with concrete commands and results, and the checklist is complete. The template's optional screenshot section is absent, which is acceptable. The template's test-plan checkboxes for the workspace test command and the docs update are not ticked, and the description does not explain why they were skipped. The description also lacks an explicit statement that the workspace test suite was run. These are minor gaps.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ca222cf4-567a-4490-a401-0d9d4bd38fbc
Commits

Reviewing files that changed from the base of the PR and between 28f364b and ba09c7f.

Files selected for processing: 2

  • crates/perry-runtime/src/array/mod.rs
  • scripts/addr_class_allowlist.txt

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 0 remain after this review.

ralic and others added 3 commits November 16, 2026 15:20
…through the checked probes

The addr-class audit has failed on main since 0b2c663 (PerryTS#14430) gave
layout_slot.rs its own copy of array_gc_header, with a hand-rolled
GC_HEADER_SIZE + 0x1000 floor that does not reject the handle bands.
Later instrumented-only code added unvalidated GcHeader casts.

- layout_slot uses array::array_gc_header (now pub(crate)), the one
  grandfathered probe, instead of a second copy with its own floor.
- fill_birth's test reads the header through array_gc_header.
- The LIFE census (instr builds only) reads a birth or region address
  through try_read_gc_header / is_plausible_heap_addr: a POINTER_TAG
  payload there can be a handle-band id, which has no header.
- The allocator-owned header walks in alloc_life (the inline slow
  call's header, the inline burst walk) and the snapshot census's
  inventory and holder walk get allowlist entries naming where each
  address comes from.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p
Main added snap_image.rs (PerryTS#14765, PerryTS#14775) and a census reachability walk in snap_census/inventory.rs. Their GcHeader casts read headers from arena_walk_objects / MALLOC_STATE at a cut that collects nothing; the tls_window unit test uses a synthetic thread pointer. Each gets a narrow allowlist entry naming the source.
@TheHypnoo
TheHypnoo merged commit f30c7ab into PerryTS:main Nov 16, 2026
114 of 134 checks passed
@raliclo
raliclo deleted the fix/lint-addrclass branch November 17, 2026 01:36
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