Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex hang - enormous memory consumption #5530

Open
paulprocacci opened this issue Feb 22, 2024 · 1 comment
Open

Regex hang - enormous memory consumption #5530

paulprocacci opened this issue Feb 22, 2024 · 1 comment
Labels
Addressed in RakuAST This issue will be addressed in RakuAST edge cases Overflow, underflow, limits, boundaries, extreme large/small, negative or unexpected values

Comments

@paulprocacci
Copy link

paulprocacci commented Feb 22, 2024

The Problem

Given the following:

my $line = '      media: Ethernet autoselect (1000baseT <full-duplex>)';
say $<media> if $line ~~ / ^ \s+ 'media: ' $<media> = [ <![\(]>+ ] $ /;

Raku is spinning spinning spinning.

Expected Behavior

I expect raku surely not to hang spinning on ~20 characters is needs to go through.

Actual Behavior

After just 5 seconds of runtime for the above:

PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
97367 root 2 129 0 1385M 1139M CPU6 6 0:22 100.07% rakudo

Steps to Reproduce

Run what I've provided.

Environment

  • Operating system:
    FreeBSD 14.0-RELEASE

  • Compiler version (rakudo -v or raku -v):
    raku -v
    Welcome to Rakudo™ v2024.01.
    Implementing the Raku® Programming Language v6.d.
    Built on MoarVM version 2024.01.

Note the same thing happened w/ the last 2023 release.

It shall be known that what I provided <![(]+> should have been <-[(]]+>.
I understand this. I'm documenting the behavior, not the syntax.

@lizmat
Copy link
Contributor

lizmat commented Feb 22, 2024

I guess it's one of those cases where the regex engine gets into an infiniloop. It's my hope we will be able to catch those cases in RakuAST.

@lizmat lizmat added the Addressed in RakuAST This issue will be addressed in RakuAST label Feb 22, 2024
@ab5tract ab5tract added the edge cases Overflow, underflow, limits, boundaries, extreme large/small, negative or unexpected values label Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Addressed in RakuAST This issue will be addressed in RakuAST edge cases Overflow, underflow, limits, boundaries, extreme large/small, negative or unexpected values
Projects
None yet
Development

No branches or pull requests

3 participants