Skip to content

fix: release captured and hash-slice temporary owners - #1204

Merged
fglock merged 18 commits into
masterfrom
fix/issue-1132-closure-lifetime
Sep 2, 2026
Merged

fix: release captured and hash-slice temporary owners#1204
fglock merged 18 commits into
masterfrom
fix/issue-1132-closure-lifetime

Conversation

@fglock

@fglock fglock commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Summary

Fix selective-reference-count owner leaks exposed by Net::Async::HTTP and
restore global destruction for discarded eval captures:

  • Release captured closure owners when a temporary global IO::Async notifier
    owner is removed.
  • Transfer compiler-created interpreter HASH_SLICE_SET RHS and staging
    owners once RuntimeHash.setSlice() has created the durable slots.
  • Release a scope-exited eval capture's semantic owner at the pre-END
    boundary only when no END block can reach it.

The second fix resolves the exact t/32remove.t connection count: the
interpreter now reports 4 references during removal and 1 at EOF, matching
system Perl and the JVM backend. The third restores run/fresh_perl.t test 75
to the 73/91 baseline by allowing the typed lexical referent's DESTROY to
run at global destruction.

Validation

  • prove for the two new focused owner regressions on system Perl.
  • Focused owner regressions on JVM and interpreter.
  • make (full unit suite), including the final regression-fix gate.
  • make check-links.
  • Net::Async::HTTP 0.50 t/30timeout.t: 25/25 on JVM and interpreter.
  • Net::Async::HTTP 0.50 t/32remove.t: 3/3 on JVM and interpreter.
  • Perl core run/fresh_perl.t: test 75 passes on JVM and with the interpreter
    forced globally; the default JVM result is restored to 73/91 with the same
    18 historical failures.

@fglock fglock changed the title WIP: investigate closure capture ownership fix: release captured closure owners after global removal Sep 1, 2026
@fglock fglock changed the title fix: release captured closure owners after global removal fix: release captured and hash-slice temporary owners Sep 1, 2026
fglock and others added 17 commits September 1, 2026 23:49
Add the issue #1132 regression, document the failed per-capture accounting
approach, and record the owner-ledger design for a Perl-exact implementation.

Known limitation: the current partial RuntimeScalar change does not yet pass
the focused regression or the full make gate; follow-up work starts from the
owner-ledger design.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <2237389410+openai-codex[bot]@users.noreply.github.com>
Model a captured pad as one semantic owner shared by all closures, and
consult that ownership during weak-reference cleanup. Transfer the owner on
reassignment and release it on weaken, unweaken, and final capture release.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <2237389410+openai-codex[bot]@users.noreply.github.com>
Honor semantic capture owners at the weak-reference clearing boundary, and
allow their lifecycle lookup through WEAKLY_TRACKED states. Add a focused,
system-Perl-validated weak callback-slot regression and record the Future and
Net::Async::HTTP acceptance evidence in the owner-ledger design.

Generated with Codex (OpenAI)

Co-Authored-By: Codex <codex@openai.com>
Document the remaining JVM closure-captured socket return boundary and retain
the focused IO::Socket fileno regression while that case is completed.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Explicit JVM returns now clean only frame-local scalar slots, leaving an
enclosing closure capture responsible for an anonymous socket assigned during
the callback.

Refs: dev/design/refcount-owner-ledger.md

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Keep the DBIx aggregate compatibility adjustment inside DESTROY so ordinary
fresh lexical B probes report their single owner. Expose diagnostic owner
counts for the remaining IO::Async scalar-store investigation and update the
Issue #1132 handoff.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Keep trace-only source provenance for deferred scalar releases until drain or
cancellation, and record the completed diagnostic step in the owner-ledger
design.

Generated with [Codex](https://openai.com/codex/)

Co-Authored-By: Codex <codex@openai.com>
Expose active and queued owner provenance for a selected referent without
creating diagnostic reachability, and record the next Net exact-count step.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Document that the remaining Net exact-count surplus is not captured-pad,
scalar-store, or missed-boundary ownership.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Track method-invocant and blessing-temporary holds in the owner trace, and
keep parallel deferred trace metadata aligned with scoped queue drains.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Record scalar-reference, weak-promotion, closure-capture, and tie-wrapper
holds in assertion-boundary owner traces. Document that the JVM-only Net
timeout excess remains outside these paths.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Include semantic captured-pad owner counts in assertion-boundary snapshots
and record the JVM-only Net::Async::HTTP investigation handoff.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Record PR 1204 as the required continuation target, the exact diagnostic
state, retained commits, and receiving-worker validation responsibility.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Always schedule the captured scalar's normal deferred decrement. The former
reachability-based transfer discarded a capture count while an IO::Async loop
temporarily owned the object and never restored it after notifier removal.

Add a system-Perl-validated exact-refcount regression and document the
Net::Async::HTTP 0.50 t/30timeout.t JVM/interpreter verification.

Generated with [OpenAI Codex](https://openai.com/codex/)

Co-Authored-By: OpenAI Codex <codex@openai.com>
Transfer compiler-created RHS and staging scalar-store owners after
HASH_SLICE_SET creates durable hash slots. This fixes the interpreter-only
Net::Async::HTTP t/32remove exact-refcount drift and adds permanent coverage.

Refs: dev/design/refcount-owner-ledger.md

Generated with [OpenAI Codex](https://openai.com/codex/)
Co-Authored-By: OpenAI Codex <codex@openai.com>
@fglock
fglock force-pushed the fix/issue-1132-closure-lifetime branch from 01b82f9 to d6a489c Compare September 1, 2026 21:55
@fglock
fglock marked this pull request as ready for review September 1, 2026 21:55
Release a scope-exited captured pad's semantic owner at the pre-END boundary
when no END block can reach it. This restores DESTROY for discarded eval
captures and returns Perl core run/fresh_perl.t to its 73/91 baseline.

Refs: dev/design/refcount-owner-ledger.md

Generated with [OpenAI Codex](https://openai.com/codex/)

Co-Authored-By: OpenAI Codex <codex@openai.com>
@fglock
fglock merged commit e20a49b into master Sep 2, 2026
2 checks passed
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