Menu

#2634 4.3pre6 regexp find: hangs + huge memory waste

severe bug
closed-fixed
5
2006-08-19
2006-08-16
No

When you do "Find" or "Find and Replace" or "Replace
All" with the regular expression "$" (match end of
line), 4.3pre6 just hangs while its memory-usage meter
thing in the bottom-right-hand-side of its status bar
shows memory usage increasing exponentially!

Also, this happens regardless of whether the search is
performed within a selection, the current buffer, all
buffers, or within a directory.

To reproduce this bug:

1. Make a new buffer with this content:

foo
bar
baz

2. Select all the text (C-a)

3. Open search&replace dialog (C-f)

4. Type the following regexp in the "search for" field:

$

5. Enable the "regular expressions" check-box (A-x)

7. Press the "Find" or "Find and Replace" or "Replace
All" button.

8. Observe that jEdit now hangs, and its memory usage
is rapidly increasing (look at memory usage stats at
bottom-right-hand-corner of status bar).

The expected result is that jEdit should NOT hang and
the search should be performed correctly.

Thanks for your attention.

Discussion

  • Suraj Kurapati

    Suraj Kurapati - 2006-08-16
    • summary: 4.3pre6 regexp find in selection: hangs + huge memory waste --> 4.3pre6 regexp find: hangs + huge memory waste
     
  • Marcelo Vanzin

    Marcelo Vanzin - 2006-08-19

    Logged In: YES
    user_id=75113

    Seems to be a problem with a combination of HyperSearch and
    a side-effect of using "$" as the search regex.

    When using "$", the matcher will always match the same
    element. Meaning that it will first match the end of the
    line where the caret is, and subsequent calls to
    "PatternSearchMatcher.nextMatch()" will match the same
    end-of-line as the previous call.

    When doing an HyperSearch, the code will loop until
    "nextMatch()" returns a match that is at the end of the
    region being searched. Since nextMatch() will be stuck at
    the same spot, it will never reach the end of the region,
    and hypersearch will keep collecting the match results until
    we run out of memory.

    I'm trying to find a way to have the matcher go to the next
    line if the current position is at the end of the line, that
    should fix it.

     
  • Marcelo Vanzin

    Marcelo Vanzin - 2006-08-19
    • assigned_to: nobody --> vanza
     
  • Marcelo Vanzin

    Marcelo Vanzin - 2006-08-19

    Logged In: YES
    user_id=75113

    Fixed in SVN revision #6702.

     
  • Marcelo Vanzin

    Marcelo Vanzin - 2006-08-19
    • status: open --> closed-fixed
     
  • Suraj Kurapati

    Suraj Kurapati - 2006-08-19

    Logged In: YES
    user_id=315014

    A new problem has been created by the fix in svn #6702: the
    end-of-line is not being preserved when doing find & replace.

    For example,

    1. Make a new buffer with this content:

    foo
    bar
    baz

    2. Select all the text (C-a)

    3. Open search&replace dialog (C-f)

    4. Type the following regexp in the "search for" field:

    $

    6. Type the following text in the "replace with" field:

    |

    7. Enable the "regular expressions" check-box (A-x)

    8. Press the "Replace All" button.

    8. Observe that the buffer now contains:

    foo|bar|baz|

    The expected result is that the buffer should contain:

    foo|
    bar|
    baz|

    Thanks for your attention.

     
  • Suraj Kurapati

    Suraj Kurapati - 2006-08-19
    • status: closed-fixed --> pending-remind
     
  • Marcelo Vanzin

    Marcelo Vanzin - 2006-08-19
    • status: pending-remind --> closed-fixed
     
  • Marcelo Vanzin

    Marcelo Vanzin - 2006-08-19

    Logged In: YES
    user_id=75113

    Revision #6704 as a better fix that maintains the correct
    "replace" behavior.

     

Log in to post a comment.

MongoDB Logo MongoDB