Honor $^P subroutine tracing when populating %DB::sub
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Perl
- 星标
- 67
- 派生
- 8
- 平均合并
- 5 小时 12 分钟
- 30 天内合并 PR
- 131
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fglock/PerlOnJava 的其他 Issue
-
area:cpan-port bug
难度 2/5 1-3 小时 新手友好度 70/100
fglock/PerlOnJava#2153 ·
维护者通常 1 天内回复
-
area:cpan-port area:parser bug
难度 2/5 1-3 小时 新手友好度 68/100
fglock/PerlOnJava#2137 ·
维护者通常 1 天内回复
-
area:backend area:cpan-port area:runtime bug
难度 2/5 1-3 小时 新手友好度 76/100
fglock/PerlOnJava#2071 ·
维护者通常 1 天内回复
-
area:runtime documentation enhancement
难度 2/5 1-3 小时 新手友好度 72/100
fglock/PerlOnJava#1579 ·
维护者通常 1 天内回复
-
area:cpan-port bug
难度 3/5 1-2 天 新手友好度 62/100
fglock/PerlOnJava#2157 ·
维护者通常 1 天内回复
查看 fglock/PerlOnJava 的全部 Issue
相似的 Issue
-
Dev-output directory preparation accepts file-valued lib/include paths and fails on dangling links未关闭team-cli
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
-
难度 1/5 1 小时以内 新手友好度 93/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
inverse-inc/packetfence#9728 ·
维护者通常 1 天内回复
-
fix(char-create): show the real reason a character is refused可能已有人在做 @baphomello 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复