Honor $^P subroutine tracing when populating %DB::sub
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 31/100
Research direction
Start in BytecodeCompiler and SubroutineParser where named-sub source registration is gated on DebugState.isDebugMode(), and find where Perl's $^P is stored and mutated so the 0x10 bit can feed that gate. Then check that %DB::sub entries are written with the defining filename, and validate against system Perl with a new focused test before running the unchanged Module-Refresh t/1api.t and t/clear_symtable.t on both the JVM and interpreter backends. Done means those two tests pass and -d debugger tracing still behaves as before.
Written by the indexing model from the issue text.
Description
Summary
PerlOnJava does not populate %DB::sub when Perl code enables subroutine source tracing with $^P |= 0x10. Pure-Perl modules such as Module::Refresh rely on this documented Perl behavior to locate and unload subs defined by a changed file. As a result, refreshed modules retain old methods after reload.
Reproduction and evidence
The unchanged Module-Refresh 0.18 test suite passes under system Perl 5.34.1 (4 files, 16 tests). In CPAN random tester run 20261119-133823-51077, PerlOnJava failed 2 of 16 assertions:
t/1api.t, test 8:We cleaned out the 'foo' methodt/clear_symtable.t, test 4:!Foo->can('bar')
Both failures reproduce on the JVM and interpreter backends in the PerlOnJava checkout at 75525a5dc (2026-11-20), after the symbol-table/method-lookup changes integrated by #1773. The test demonstrates that the old Foo::bar remains callable after Foo.pm is refreshed with a replacement Foo::baz.
A focused diagnostic also sets $^P |= 0x10, loads a file declaring Foo::bar, then inspects %DB::sub: PerlOnJava reports no Foo:: entries while Foo->can('bar') is true. The normal system-Perl run of the complete distribution suite passes.
Environment: macOS 26.7.3, Temurin OpenJDK 24.0.2, system Perl 5.34.1.
Root cause
Module::Refresh sets $^P |= 0x10 in its BEGIN block. Its unload_subs method finds candidate routines by matching each %DB::sub source-location value against the module filename; if no entries match, it cannot remove those routines before require reloads the file.
PerlOnJava currently gates named-sub location registration in BytecodeCompiler and SubroutineParser on DebugState.isDebugMode(). That internal state is enabled by the command-line debugger path, but setting Perl's $^P bit from Perl code does not enable the corresponding subroutine-tracing behavior. Consequently, dynamically loaded modules can compile named subs without registering their source locations in %DB::sub, and Module::Refresh silently leaves old subs installed.
This is related to #1610, which covered stale method lookup after deleting a CODE slot and was integrated in #1773. The current report tracks the separate missing $^P/%DB::sub behavior; the Module::Refresh failures recorded on #1610 still reproduce after that integration.
Expected behavior
When Perl code enables the 0x10 subroutine source-tracing bit in $^P, named subs compiled afterward should appear in %DB::sub with source locations that identify their defining file. Module::Refresh must then be able to remove the previous file's subs, and the refreshed package should expose only the replacement methods.
Acceptance criteria
- Add a focused project-owned Perl test for enabling
$^Pbit0x10and observing source entries for subsequently compiled named subs; validate its expected behavior with system Perl first. - Pass that regression on both JVM and interpreter backends.
- Pass the unchanged
Module-Refresh0.18 suite on both backends, includingt/1api.tandt/clear_symtable.t. - Preserve command-line debugger behavior and verify
%DB::subremains consistent when tracing is enabled through$^Prather than-d.
- Dominant language
- Perl
- Stars
- 67
- Forks
- 8
- Avg merge
- 5h 12m
- Merged PRs (30d)
- 131
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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 bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
fglock/PerlOnJava#2153 ·
Maintainers usually reply within 1 day
-
area:cpan-port area:parser bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
fglock/PerlOnJava#2137 ·
Maintainers usually reply within 1 day
-
area:backend area:cpan-port area:runtime bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
fglock/PerlOnJava#2071 ·
Maintainers usually reply within 1 day
-
area:runtime documentation enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
fglock/PerlOnJava#1579 ·
Maintainers usually reply within 1 day
-
area:cpan-port bug
Difficulty 3/5 1-2 days Newbie friendliness 62/100
fglock/PerlOnJava#2157 ·
Maintainers usually reply within 1 day
All issues in fglock/PerlOnJava
Similar issues
-
Dev-output directory preparation accepts file-valued lib/include paths and fails on dangling linksOpenteam-cli
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 1/5 Under an hour Newbie friendliness 93/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
inverse-inc/packetfence#9728 ·
Maintainers usually reply within 1 day
-
fix(char-create): show the real reason a character is refusedPossibly taken @baphomello claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day