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

hang on 100% CPU usage when editing certain regex #30

Open
litoj opened this issue Aug 15, 2024 · 0 comments
Open

hang on 100% CPU usage when editing certain regex #30

litoj opened this issue Aug 15, 2024 · 0 comments

Comments

@litoj
Copy link

litoj commented Aug 15, 2024

Describe the bug

When trying to edit certain regexes, nvim started hanging on me with 100% CPU usage.

To Reproduce

I've minified the regex to the minimum amount of characters needed to reproduce the bug. Originally, the escape key was there to match ansi sequences.

  • x.txt

  • neovim with bash & regex parsers installed:

    :e /tmp/x.txt
    10lx
    

Expected behavior

the closing parenthese gets deleted

Syntax tree:

(added x to the empty group to remove one syntax error)

        (pattern ; [0, 9] - [0, 25]
          (alternation ; [0, 9] - [0, 25]
            (term ; [0, 9] - [0, 12]
              (anonymous_capturing_group ; [0, 9] - [0, 12]
                (pattern ; [0, 10] - [0, 11]
                  (term ; [0, 10] - [0, 11]
                    (pattern_character))))) ; [0, 10] - [0, 11]
            (term ; [0, 13] - [0, 25]
              (anonymous_capturing_group ; [0, 13] - [0, 25]
                (pattern ; [0, 14] - [0, 24]
                  (term ; [0, 14] - [0, 24]
                    (end_assertion) ; [0, 14] - [0, 15]
                    (ERROR) ; [0, 15] - [0, 16]
                    (pattern_character) ; [0, 16] - [0, 17]
                    (character_class ; [0, 17] - [0, 20]
                      (class_character)) ; [0, 18] - [0, 19]
                    (pattern_character) ; [0, 20] - [0, 21]
                    (pattern_character) ; [0, 21] - [0, 22]
                    (pattern_character) ; [0, 22] - [0, 23]
                    (pattern_character))))))) ; [0, 23] - [0, 24]

In terms of highlighting, the issue is that in bash the regex string can also contain bash variables and their syntax, but the parser doesn't detect that, so it tries to parse it as usual. But the freeze is the real issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant