Skip to content

chore(lint): allowlist guarded GcHeader probe in collection_proto_thunks (#6659) - #6722

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
proggeramlug:fix/6659-addr-class-allowlist-collection-proto-thunks
Jul 20, 2026
Merged

chore(lint): allowlist guarded GcHeader probe in collection_proto_thunks (#6659)#6722
proggeramlug merged 1 commit into
PerryTS:mainfrom
proggeramlug:fix/6659-addr-class-allowlist-collection-proto-thunks

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Problem

The lint gate is red on main and on every open PR (verified: #6721, #6720, #6717, #6712, #6711 all fail lint identically). The failing step is the address-classification audit (scripts/addr_class_inventory.py):

crates/perry-runtime/src/object/collection_proto_thunks.rs:329: [gcheader-cast]
  (*((ptr as *const u8).sub(crate::gc::GC_HEADER_SIZE) as *const crate::gc::GcHeader))

This GcHeader obj_type probe was added by #6659 (fac2bbead, merged 2026-07-19) without an allowlist entry, so the ratchet has been failing lint for every PR branched from that point.

Why an allowlist entry is the right fix

The cast is already correctly magnitude-classified — it runs only inside:

if crate::value::addr_class::is_above_handle_band(ptr)
    && crate::object::is_valid_obj_ptr(ptr as *const u8)
{
    let obj_type = unsafe {
        (*((ptr as *const u8).sub(crate::gc::GC_HEADER_SIZE) as *const crate::gc::GcHeader)).obj_type
    };

So ptr is never a handle-band small integer at the deref — exactly the invariant the ratchet exists to enforce. This is the same shape as the sibling object/* probes already in the allowlist, so I added one line with a follow-up note to migrate it to addr_class::try_read_gc_header.

Change

One line in scripts/addr_class_allowlist.txt. No functional change.

Verification

All five lint steps pass locally on this branch: cargo fmt --all -- --check, benchmark-freshness, check_file_size.sh, GC store-site inventory, and the address-classification audit (self-test + full run, exit 0). Restores lint to green, which unblocks all currently-open PRs.

No version bump / changelog — maintainer folds metadata at merge.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated audit exemptions to document a guarded runtime object-type check.
    • Recorded a follow-up migration for improved address validation.

…_thunks (PerryTS#6659)

PerryTS#6659 (fac2bbe) added a `(ptr as *const u8).sub(GC_HEADER_SIZE) as *const GcHeader`
obj_type probe in collection_proto_thunks.rs without an addr-class allowlist entry,
so the address-classification audit (the `lint` gate) went red on main and on every
open PR branched from it.

The probe is correctly magnitude-classified — it runs only inside
`if is_above_handle_band(ptr) && is_valid_obj_ptr(ptr as *const u8)`, so the pointer
is never a handle-band small integer at the deref. Add the standard allowlist entry
(same shape as the sibling object/* probes) with a follow-up note to migrate it to
`addr_class::try_read_gc_header`.

Restores lint to green; no functional change.
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds one address-classification allowlist entry documenting a guarded GcHeader probe in collection_proto_thunks.rs and its planned migration to addr_class::try_read_gc_header.

Changes

Address classification

Layer / File(s) Summary
Add guarded probe exemption
scripts/addr_class_allowlist.txt
Adds an allowlist entry for the guarded GcHeader object-type probe and records the planned migration path.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: thehypnoo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the PR adds a guarded GcHeader probe allowlist entry in collection_proto_thunks.rs.
Description check ✅ Passed The description covers the problem, change, and verification, though it doesn't follow the repo's template exactly.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/addr_class_allowlist.txt`:
- Line 139: Update the allowlist entry for collection_proto_thunks.rs to replace
the broad “*” match with the exact GcHeader cast/probe substring being
grandfathered. Preserve the existing guard context and comment, while ensuring
future GcHeader casts in that file are not automatically allowlisted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 95fd6449-ccac-4704-be3e-dcd68000f2bc

📥 Commits

Reviewing files that changed from the base of the PR and between 53909ce and f4169b2.

📒 Files selected for processing (1)
  • scripts/addr_class_allowlist.txt

crates/perry-runtime/src/object/class_registry/ | * | pre-existing GcHeader probe predating addr_class; address validated by call-site guards (magnitude/registry/is_valid_obj_ptr) -- migrate to addr_class::try_read_gc_header in a follow-up (split of class_registry.rs)
crates/perry-runtime/src/object/descriptor_state.rs | * | pre-existing GcHeader probe predating addr_class; address validated by call-site guards (magnitude/registry/is_valid_obj_ptr) -- migrate to addr_class::try_read_gc_header in a follow-up (split of object/mod.rs)
crates/perry-runtime/src/object/to_string_tag.rs | * | pre-existing GcHeader probe predating addr_class; address validated by call-site guards (magnitude/registry/is_valid_obj_ptr) -- migrate to addr_class::try_read_gc_header in a follow-up (split of object/mod.rs)
crates/perry-runtime/src/object/collection_proto_thunks.rs | * | GcHeader obj_type probe guarded by is_above_handle_band + is_valid_obj_ptr (magnitude-classified before the deref); migrate to addr_class::try_read_gc_header in a follow-up (added in #6659)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Narrow the allowlist match to the specific probe.

Using * suppresses every future GcHeader-cast finding in collection_proto_thunks.rs, not just the guarded probe being grandfathered. Replace the wildcard with the exact cast substring so newly added unsafe probes cannot bypass the audit.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/addr_class_allowlist.txt` at line 139, Update the allowlist entry for
collection_proto_thunks.rs to replace the broad “*” match with the exact
GcHeader cast/probe substring being grandfathered. Preserve the existing guard
context and comment, while ensuring future GcHeader casts in that file are not
automatically allowlisted.

@proggeramlug
proggeramlug merged commit d9fc949 into PerryTS:main Jul 20, 2026
23 of 26 checks passed
@proggeramlug
proggeramlug deleted the fix/6659-addr-class-allowlist-collection-proto-thunks branch July 20, 2026 11:56
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