-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Python 3.11.0b3 chockes on regex sub from rjsmin, time grows seemingly exponentially #94675
Comments
A more "real" example is to pipe the javascript input to https://github.com/ndparker/rjsmin/blob/1.2.0/rjsmin.py
|
I've simplified the regex to: pattern = '(?<=[(,=:\\[!&|?{};\\r\\n+*-])(?:[\\000-\\011\\013\\014\\016-\\040]|(?:/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*/))*(?:(?:(?://[^\\r\\n]*)?[\\r\\n])(?:[\\000-\\011\\013\\014\\016-\\040]|(?:/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*/))*)*((?:/(?![\\r\\n/*])[^/\\\\\\[\\r\\n]*(?:(?:\\\\[^\\r\\n]|(?:\\[[^\\\\\\]\\r\\n]*(?:\\\\[^\\r\\n][^\\\\\\]\\r\\n]*)*\\]))[^/\\\\\\[\\r\\n]*)*/[a-z]*))((?:[\\000-\\011\\013\\014\\016-\\040]|(?:/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*/))*(?:(?:(?://[^\\r\\n]*)?[\\r\\n])(?:[\\000-\\011\\013\\014\\016-\\040]|(?:/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*/))*)+(?=[^\\000-\\040&)+,.:;=?\\]|}-]))?' The following ones are even shorter and exhibit the same behavior but slightly different times, so I am not editing it in the original report:
|
Can you repro on latest main? |
(If #93928 did indeed fix, it would be nice to add your reduced example as a test case!) |
Will test. |
This is fixed on main. |
#93928 also fixes it on 3.11 |
@hauntsaninja Any idea how are the "does not take too long" cases handled in cpython tests? |
I've added #94685 -- hoping that the general timeout thing would stop it on b3 |
Use multiprocessing to kill the test after SHORT_TIMEOUT.
This fixes a speed regression in the re module which prevented chromium from building in Fedora. Revert "bpo-23689: re module, fix memory leak when a match is terminated by a signal or memory allocation failure" This reverts commit 6e3eee5. Manual fixups to increase the MAGIC number and to handle conflicts with a couple of changes that landed after that. (cherry picked from commit 4beee0c) Co-authored-by: Gregory P. Smith <greg@krypto.org> pythongh-94675: Add a regression test for rjsmin re slowdown Co-authored-by: Miro Hrončok <miro@hroncok.cz>
This tests a speed regression in the re module which prevented chromium from building in Fedora. python#94685
This tests a speed regression in the re module which prevented chromium from building in Fedora. python#94685
…H-94685) Adds a regression test for an re slowdown observed by rjsmin. Uses multiprocessing to kill the test after SHORT_TIMEOUT. Co-authored-by: Oleg Iarygin <dralife@yandex.ru> Co-authored-by: Christian Heimes <christian@python.org> (cherry picked from commit fe23c00) Co-authored-by: Miro Hrončok <miro@hroncok.cz>
Adds a regression test for an re slowdown observed by rjsmin. Uses multiprocessing to kill the test after SHORT_TIMEOUT. Co-authored-by: Oleg Iarygin <dralife@yandex.ru> Co-authored-by: Christian Heimes <christian@python.org>
Adds a regression test for an re slowdown observed by rjsmin. Uses multiprocessing to kill the test after SHORT_TIMEOUT. Co-authored-by: Oleg Iarygin <dralife@yandex.ru> Co-authored-by: Christian Heimes <christian@python.org> (cherry picked from commit fe23c00) Co-authored-by: Miro Hrončok <miro@hroncok.cz>
Fixed by #94685 |
…uilding For details, see python/cpython#94675 Backported from upstream 3.11 branch + python/cpython#94685 Needs bootstrap for test_distutils (assert _sre.MAGIC == MAGIC, "SRE module mismatch").
Bug report
When building chromium in Fedora 37 with Python 3.11.0b3, the build hangs seemingly forever.
While isolating the hang, we've noticed it happens in rjsmin, at https://github.com/ndparker/rjsmin/blob/1.2.0/rjsmin.py#L361
I've further reduced the javascript input as much as I could
but I kept the regex pattern intact.Here's the reporucer:
The original input reduced from Chromium's JavaScript file looks like:
And here how long it takes with Python 3.10.5 and 3.11.0b3 for a reduced number of slashes.
For 74 slashes, I guess it would run forever.
Your environment
The text was updated successfully, but these errors were encountered: