Honor $^P subroutine tracing when populating %DB::sub
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 31/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Perl
- Estrelas
- 67
- Forks
- 8
- Merge médio
- 5h 12min
- PRs com merge (30d)
- 131
Preparar o ambiente
- Inclui um Dockerfile ou arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de fglock/PerlOnJava
-
area:cpan-port bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
fglock/PerlOnJava#2153 ·
Mantenedores costumam responder em até 1 dia
-
area:cpan-port area:parser bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
fglock/PerlOnJava#2137 ·
Mantenedores costumam responder em até 1 dia
-
area:backend area:cpan-port area:runtime bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
fglock/PerlOnJava#2071 ·
Mantenedores costumam responder em até 1 dia
-
area:runtime documentation enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
fglock/PerlOnJava#1579 ·
Mantenedores costumam responder em até 1 dia
-
area:cpan-port bug
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 62/100
fglock/PerlOnJava#2157 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de fglock/PerlOnJava
Issues semelhantes
-
Dev-output directory preparation accepts file-valued lib/include paths and fails on dangling linksAbertateam-cli
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 93/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
inverse-inc/packetfence#9728 ·
Mantenedores costumam responder em até 1 dia
-
fix(char-create): show the real reason a character is refusedTalvez já em andamento @baphomello assumiu há 1 dia. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
Mantenedores costumam responder em até 1 dia