Bug 60668

Summary: Sub optimal regular expressions makes JMeter freeze (catastrophic backtracking regex)
Product: JMeter - Now in Github Reporter: chamath <chamath.allneeds>
Component: MainAssignee: JMeter issues mailing list <issues>
Status: NEEDINFO ---    
Severity: enhancement CC: p.mouawad
Priority: P2    
Version: 2.9   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: RegExp that got stuck.

Description chamath 2017-01-31 04:53:51 UTC
Created attachment 34695 [details]
RegExp that got stuck.

Every time I provide a invalid symbol to a regExp Tester, jmeter tool gets stuck and I will have to close the application and start the recording from the beginning.

attached is a screen shot of the invalid RegExp that got stuck.
Comment 1 Philippe Mouawad 2017-02-01 19:39:44 UTC
Hello,
Could you provide the HTML code (as a text file) that is shown in screenshot and the regexp as text (not image) ?

Thank you
Comment 2 Felix Schumacher 2017-02-01 20:31:49 UTC
The used regex is badly composed and will take a long time on moderately long inputs.

The important pieces here are, that the matching is done in the awt thread and thus blocking the GUI. Secondly Java has no standard way to interrupt regex matches.

On
http://stackoverflow.com/questions/910740/cancelling-a-long-running-regex-match
Is a nice wrapper for charsequence, which in combination with a thread can be used to make the matching interruptible.

I think I can produce a patch, but it will probably take a few days.
Comment 3 Philippe Mouawad 2017-02-01 20:44:30 UTC
(In reply to Felix Schumacher from comment #2)
> The used regex is badly composed and will take a long time on moderately
> long inputs.
> 
> The important pieces here are, that the matching is done in the awt thread
> and thus blocking the GUI. Secondly Java has no standard way to interrupt
> regex matches.
> 
> On
> http://stackoverflow.com/questions/910740/cancelling-a-long-running-regex-
> match
> Is a nice wrapper for charsequence, which in combination with a thread can
> be used to make the matching interruptible.
> 
> I think I can produce a patch, but it will probably take a few days.

Hi Felix,
Do you think it's worth the work ?

Badly built Regex can lead to catastrophic backtracking that would kill performance of Load Test anyway.

Regards
Comment 4 Felix Schumacher 2017-02-01 20:55:47 UTC
The use case is about testing a regex in the GUI. Not about using it in the tests.

It would probably help to indicate, that a regex takes too long, even when used in the GUI.

But I think this is more a minor bug.
Comment 5 The ASF infrastructure team 2022-09-24 20:38:07 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/4256