-
Notifications
You must be signed in to change notification settings - Fork 846
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
regexp hangs forever #1189
Comments
Hi, Its unfortunate that you ran into this. Tested this in Chrome and also quite slow there. Think this is just a limitation of many regex implementations out there, see https://v8.dev/blog/non-backtracking-regexp for an explanation of the problem/challenge. As for your request for adding the |
https://github.com/makenowjust-labs/recheck |
In general, JavaScript regexp are powerful enough that there will always be some that are very slow, even in browsers. For example:
(If you try this in Chrome dev tools, be prepared to kill the browser tab) We are currently still using Rhino to run JavaScript regexps, in order to perform server validation of some client side browser code. Until now we started a separate thread and used the deprecated Somewhere between Java 17 and 21, As such, a way to interrupt long running regexp would definitely be great. I'll try and clone this repo locally to see if the check for Thread.interrupted would work. |
Uses Thread.currentThread.isInterrupted() so that the interruption flag remains set to true, we only terminate the RegExp evaluation loop, but other (potentially third-party calling) code may still have to check for the interrupted flag to stop its execution as well. I also added a test with a long-running regexp that fails without the interrupt check.
* Make regexp execution loop interruptible #1189 Uses Thread.currentThread.isInterrupted() so that the interruption flag remains set to true, we only terminate the RegExp evaluation loop, but other (potentially third-party calling) code may still have to check for the interrupted flag to stop its execution as well. I also added a test with a long-running regexp that fails without the interrupt check. Co-authored-by: Andre Wachsmuth <[email protected]>
This code hangs forever (or is incredible slow). Tested in Rhino 1.7.14
Also the regexp code is non-interruptible. Please add
if (Thread.interrupted()) ...
to the regexp evaluation loopThe text was updated successfully, but these errors were encountered: