Skip to content

Joni regex compilation hangs loading PPR 0.001010 on both PerlOnJava backends #1299

Description

@fglock

Summary

Loading PPR 0.001010 never completes under PerlOnJava. This blocks Babble 0.090010, which depends on PPR, from starting its test suite.

The hang is reproducible on both the JVM backend and the bytecode interpreter. System Perl loads the same PPR version successfully.

Reproduction

With PPR 0.001010 installed and available on PERL5LIB:

timeout 10 ./jperl -e 'require PPR; print "ok\n"'
timeout 10 ./jperl --interpreter -e 'require PPR; print "ok\n"'

Observed result for both commands:

exit 124

There is no ok output. The same focused load succeeds with system Perl:

timeout 30 perl -I<PPR-0.001010>/lib \\
  -e 'print STDERR "before\n"; require PPR; print STDERR "after\n"'

Observed result:

before
after
exit 0

CPAN impact

This was observed in CPAN random tester run 20260908-125510-82561:

  • Distribution: Babble 0.090010
  • Failure: timeout during Build test
  • First affected test: t/plugin-coresignatures.t
  • No TAP was emitted before the timeout
  • The archived system-Perl oracle passed Babble's complete suite: 12 files and 85 tests

The Babble failure can be reduced independently of the CPAN build tree to the PPR load command above.

Suspected root cause and ownership

PPR defines a large grammar regex at module load time:

our $GRAMMAR = qr{
    (?(DEFINE)
        ...
    )
}xms;

In PPR 0.001010 this source is approximately 170 KB. It contains extensive named subexpression definitions and calls, as well as dynamic (??{ ... }) constructs.

The hang occurs while compiling this regex, before PPR returns from require and before any Babble matching operation runs. The relevant PerlOnJava/Joni path is:

PPR.pm $GRAMMAR = qr{...}
  -> JoniRegexPattern constructor
  -> org.joni.Regex constructor
  -> org.joni.Analyser.parseRegexp()

Relevant implementation locations in the current tree:

  • src/main/java/org/perlonjava/runtime/regex/JoniRegexPattern.java:418
  • third_party/joni/src/org/joni/Regex.java:254
  • third_party/joni/src/org/joni/Analyser.java:93

This points to the Joni parser/analyser handling of a very large (?(DEFINE)) grammar, rather than Babble's test logic, runtime matching, a missing dependency, or an environmental service. Mu and MooX::ShortHas load successfully; PPR and PPR::X reproduce the hang.

Requested investigation

Please identify the specific parser/analyser recursion or state transition that fails to terminate for this grammar. A useful fix should preserve support for large named-subexpression grammars and dynamic callouts, and should include a focused project-owned regression test that does not depend on a downloaded CPAN tree.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cpan-portCPAN compatibility ports and providersarea:parserParsing compilation AST and eval behaviorarea:performancePerformance optimization and hangsarea:regexRegex/Joni/parser matchingbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions