Sub::Quote deferred subs lose identity across threads
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- perl
- Domain
- backend, testing-qa
Research direction
Start with t/sub-quote-threads.t and reproduce it on both commands shown for the JVM and interpreter backends. Read Sub/Defer.pm around line 75 and its CLONE implementation, then trace deferred-sub references and %DEFERRED across thread creation. Done means quoted and deferred subs retain their identity and the focused regression test passes on both backends.
Written by the indexing model from the issue text.
Description
Summary
Sub::Quote 2.006009 fails when quoted/deferred subs are retrieved or invoked from PerlOnJava threads. The failure reproduces on both the JVM and interpreter backends.
Reproduction
The CPAN random tester record is:
2026-09-18 07:06:07 FAIL Sub::Quote Sub::Defer ... 5430 5435 5/5435 subtests failed; 1/15 test programs failed
The failing test is:
t/sub-quote-threads.t
Using the built distribution with its library and test-library paths:
timeout 120 ./jperl -I<build>/blib/lib -I<build>/t/lib <build>/t/sub-quote-threads.t
timeout 120 ./jperl --interpreter -I<build>/blib/lib -I<build>/t/lib <build>/t/sub-quote-threads.t
Both backends fail identically: 5 of 6 assertions fail. The only passing assertion is the unquoted One case. Quoted/deferred sub retrieval and execution return undef, including the two-thread cases.
The complete CPAN run has 14 of 15 test programs passing; only t/sub-quote-threads.t fails. PerlOnJava also emits:
Use of uninitialized value in hash element at .../Sub/Defer.pm line 75
Expected behavior
System Perl passes the complete oracle run: 7036/7036 tests, including t/sub-quote-threads.t.
Technical analysis
Sub::Defer::undefer_sub looks up deferred-sub metadata in %DEFERRED using the deferred sub reference. Sub::Defer provides a CLONE implementation specifically to repair stringified subreference keys after threading.
On PerlOnJava, the lookup at Sub/Defer.pm line 75 receives an undefined or otherwise non-matching key after the thread boundary. This indicates that thread cloning is not preserving or remapping the identity/metadata of deferred quoted subs as required by Sub::Defer::CLONE.
The issue is present in both execution backends, so it appears to be shared runtime/thread-cloning behavior rather than a JVM-backend-only problem or a module-specific compilation issue.
Impact
Non-threaded Sub::Quote functionality passes, but applications using quoted/deferred subs from Perl threads can silently receive undef or fail to invoke the intended subroutine. This is a compatibility bug affecting modules that use Sub::Quote together with threads.
Suggested investigation
- Trace cloning of the deferred sub reference and the
%DEFERREDmetadata across thread creation. - Compare PerlOnJava's handling of
CLONEand stringified subreference keys with system Perl. - Add a focused project-owned regression test covering
quote_sub,quoted_from_sub,unquote_sub, and deferred-sub invocation from a child thread on both backends.
- Dominant language
- Perl
- Stars
- 64
- Forks
- 6
- Avg merge
- 5h 38m
- Merged PRs (30d)
- 170
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fglock/PerlOnJava
-
area:cpan-port area:unicode bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
fglock/PerlOnJava#1341 ·
-
area:backend area:runtime bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fglock/PerlOnJava#1511 ·
-
area:backend area:cpan-port bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fglock/PerlOnJava#1508 · 1 comment ·
-
area:cpan-port area:platform enhancement
Difficulty 5/5 Over a week Newbie friendliness 30/100
fglock/PerlOnJava#1507 ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
fglock/PerlOnJava#1506 ·
All issues in fglock/PerlOnJava
Similar issues
-
documentation Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
trizen/youtube-viewer#456 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
connectivity Open
Difficulty 1/5 Under an hour Newbie friendliness 80/100
-
Common US ingredient names are not recognized, so about 12.4k US products miss an allergen warning Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
openfoodfacts/openfoodfacts-server#14657 · 4 comments ·