Skip to content

Fix Test::Future::Deferred weak lifetime handling#833

Merged
fglock merged 3 commits into
masterfrom
fix/test-future-deferred
May 28, 2026
Merged

Fix Test::Future::Deferred weak lifetime handling#833
fglock merged 3 commits into
masterfrom
fix/test-future-deferred

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented May 28, 2026

Summary

  • Preserve returned reference scalars and closure capture owners so weak/refcount-sensitive Future and Test::Future::Deferred flows keep live referents alive only as long as Perl would.
  • Avoid capturing shadowed lexicals and avoid refcounting List::Util pair helper temporaries as local bindings.
  • Keep Sub::Quote/Moo weak metadata alive while still releasing ordinary unblessed callback captures, and guard overload stringification when an overload returns another scalar wrapper for the same referent.

Unit coverage

  • Future-style callback cleanup for unblessed captured guards.
  • Sub::Quote deferred constructor metadata used by Moo overloaded coderef generation.
  • Broken string overload returning the invocant, matching the DBIx::Class txn recursion shape.
  • Returned owned scalar and List::Util pair helper refcount cases from the Test::Future::Deferred failure chain.

Testing

  • timeout 1200 make
  • timeout 600 jperl -Iblib/lib -Iblib/arch t/01future-pp.t in Future-0.52 build
  • timeout 600 jperl -Iblib/lib -Iblib/arch t/02cancel-pp.t in Future-0.52 build
  • timeout 7200 ./jcpan -t Test::Future::Deferred
  • timeout 7200 ./jcpan -t Moo
  • timeout 7200 ./jcpan -t DBIx::Class passed on rerun (Files=314, Tests=13120, Result: PASS)

Note: an earlier DBIx::Class full run had a one-off TAP harness no-output timeout in t/sqlmaker/bind_transport.t; the file passed directly in 9s and the full DBIx::Class rerun passed.

fglock and others added 2 commits May 28, 2026 20:28
Fix reference ownership and closure capture cases exposed by Test::Future::Deferred.

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

Co-Authored-By: Codex <codex@openai.com>
Preserve captured scalar slots in bytecode-interpreter lexical assignments so closures and lvalue subs continue to alias the live lexical.

Route bytecode-interpreter assignments to `our` scalars through the declaring package global, matching interpreter reads.

Add interpreter-forced regression coverage for the captured lexical and `our` scalar assignment failures found in PR #833.

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

Co-Authored-By: Codex <codex@openai.com>
@fglock fglock force-pushed the fix/test-future-deferred branch from 75c64a6 to 9203c28 Compare May 28, 2026 19:30
Inline the small Sub::Quote/Sub::Defer behavior needed by the regression test so CI unit tests do not depend on locally installed CPAN modules.

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

Co-Authored-By: Codex <codex@openai.com>
@fglock fglock merged commit 9194868 into master May 28, 2026
2 checks passed
@fglock fglock deleted the fix/test-future-deferred branch May 28, 2026 20:38
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