Skip to content

fix(net): make the listener GC rewrite test deterministic - #8712

Merged
proggeramlug merged 1 commit into
mainfrom
merge/b19
Aug 24, 2026
Merged

proggeramlug merged 1 commit into
mainfrom
merge/b19

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Lands #8711.

gc_mutable_scanner_rewrites_listener_roots could only observe a rewrite when the collector actually moved the root — and a unit-test heap is normally too quiet for the evacuation policy to pick the copying path. So the test could pass having exercised nothing.

This is a strengthening, not a relaxation — worth saying plainly, because "make the test deterministic" is a phrase that usually means the opposite. It:

  • forces evacuation under the existing GC_TEST_LOCK, restoring any runner-supplied PERRY_GC_FORCE_EVACUATE on Drop;
  • adds an ordinary shadow-stack root as a control, whose rewrite proves the cycle copied live objects independently of scan_net_roots — so a listener left at its old address is now an actual scanner failure rather than an ambiguous result;
  • asserts the subject actually ran:
assert!(copying_minor_cycles() > before,
    "minor GC did not run the copying collector, so the scanner was not exercised");
assert!(moved_objects_total() > before,
    "copying minor did not relocate an object, so the scanner was not exercised");

That is exactly the #7024/#7025 lesson — a gate must assert its subject was live, not merely that nothing threw.

I checked the one thing that could bite: std::env::set_var is process-global, but all four tests in perry-ext-net take GC_TEST_LOCK, and each crate's tests run in their own process, so the mutation is properly serialized.

Validation

  • All 30 lint-job checkers pass
  • perry-ext-net (RUST_TEST_THREADS=1): 28 passed, 0 failed
  • Ran the target test 5× consecutively: 5/5 pass — it is in fact deterministic now, not merely passing once

Carries skip-changelog. No version bump.

Summary by CodeRabbit

  • Tests
    • Improved garbage-collection tests to verify object relocation and root updates during copying collection.
    • Added safeguards to preserve the test environment and ensure reliable cleanup after each test.

Lands #8711.

`gc_mutable_scanner_rewrites_listener_roots` could only observe a rewrite
when the collector actually moved the root, and a unit-test heap is
normally too quiet for the evacuation policy to choose the copying path --
so the test could pass having exercised nothing.

This is a strengthening, not a relaxation. It forces evacuation under the
existing GC_TEST_LOCK (restoring any runner-supplied value on Drop), adds
an ordinary shadow-stack root as a CONTROL whose rewrite proves the cycle
copied live objects independently of scan_net_roots, and asserts the
subject actually ran:

  copying_minor_cycles() > before   -- "minor GC did not run the copying
                                       collector, so the scanner was not
                                       exercised"
  moved_objects_total()  > before   -- "copying minor did not relocate an
                                       object, so the scanner was not
                                       exercised"

That is the #7024/#7025 lesson applied: a gate must assert its subject was
live, not merely that nothing threw. All four tests in the crate take
GC_TEST_LOCK, so the process-global env mutation is serialized.

Carries skip-changelog. No version bump.
@proggeramlug
proggeramlug merged commit 60f4fab into main Aug 24, 2026
@proggeramlug
proggeramlug deleted the merge/b19 branch August 24, 2026 08:13
@coderabbitai

coderabbitai Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d1e96f7a-1ac1-44d4-b2b6-baba6d4e87e8

📥 Commits

Reviewing files that changed from the base of the PR and between 2ecdd1a and 77bf735.

📒 Files selected for processing (1)
  • crates/perry-ext-net/src/tests.rs

📝 Walkthrough

Walkthrough

Changes

GC test evacuation coverage

Layer / File(s) Summary
Forced evacuation test guard
crates/perry-ext-net/src/tests.rs
GcTestGuard forces evacuation, preserves the prior PERRY_GC_FORCE_EVACUATE value, uses shadow-stack slot 1, and restores the environment during cleanup.
Scanner relocation assertions
crates/perry-ext-net/src/tests.rs
The mutable scanner test adds a control root and verifies copying collection, object movement, and rewriting of both control and listener roots.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch merge/b19

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.

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