Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Atom hangs on 100% if given a particular expression #70

Description

@Alhadis

This is somewhat difficult to explain, so please bear with me...

Last night while working on a grammar, I added a pattern-block that made Atom hang at 100% CPU usage. After force-quitting the app twice, I scrutinised the last expression for anything that might've triggered infinite recursion. I was drawing blanks until I narrowed it down from this...

    ((?:\\s*(?:'[^']*'?|[A-Za-z_∆⍙]+[\\w∆⍙¯]*|\\d+))+)
    \\s*
    ( ALPHA | BRAVO )
    \\s*
    ((?:\\s*(?:'[^']*'?|[A-Za-z_∆⍙]+[\\w∆⍙¯]*|\\d+))+)

... to this:

    ((?:\\s*(?:'[^']*'?|[A-Za-z_∆⍙]+[\\w∆⍙¯]*|\\d+))+)
    \\s*
    ( ALPHA )
    \\s*
    ((?:\\s*(?:'[^']*'?|[A-Za-z_∆⍙]+[\\w∆⍙¯]*|\\d+))+)

All of a sudden, Atom wasn't hanging whenever I switched to the tab that had the grammar's language in it. The patterns themselves didn't match anything. What the patterns were was irrelevant. What's important is that, somehow, this particular capturing group causes Atom to freeze.

I know how good First-Mate is at avoiding infinite loops, which is why this bug is concerning.
I've isolated it to a separate branch in my repo for closer examination.

Reproduction

  1. Clone and checkout the repo's bug-branch:
    git clone https://github.com/Alhadis/language-apl.git && cd language-apl
    git checkout fatal-idioms
    apm link -d . && atom -d .
  2. Open tests/life.apl. It should be fine.
  3. Run make in the package's base directory to toggle the problematic capturing group.
  4. Close tests/life.apl and restart Atom
  5. Reopen tests/life.apl

I noticed Lightshow also has troubles with this particular ruleset, although its handling is somewhat less predictable than Atom's.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions