Issue 15077: Regexp match goes into infinite loop (original) (raw)

Issue15077

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/59282

classification

Title: Regexp match goes into infinite loop
Type: crash Stage:
Components: Regular Expressions Versions: Python 2.7

process

Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, moriyoshi, mrabarnett, serhiy.storchaka
Priority: normal Keywords:

Created on 2012-06-15 10:41 by moriyoshi, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
x.py moriyoshi,2012-06-15 10:41
Messages (5)
msg162883 - (view) Author: Moriyoshi Koizumi (moriyoshi) Date: 2012-06-15 10:41
A peculiar pair of a regexp and a target string causes the runtime into an infinite loop. The same expression works with Perl.
msg162896 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-06-15 12:55
This is not infinite loop. This is O(2**len(prefix_before_first_quote)) computation. Measure times of matching for "INSER(`id`...", "INSERT(`id`...", "INSERT (`id`...", "INSERT I(`id`...", etc. Better use r'''(?:[^`';]+|'(?:'' [^'])*' `(?:``
msg164280 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-06-28 17:13
I think it's a bug. The issue can be closed.
msg164281 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-06-28 17:15
I think it's *not* a bug. The issue can be closed.
msg164283 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2012-06-28 17:36
It's not a bug, it's a pathological regex (i.e. it causes catastrophic backtracking). It also works correctly in the "regex" module.
History
Date User Action Args
2022-04-11 14:57:31 admin set github: 59282
2012-08-05 10:31:46 serhiy.storchaka set status: open -> closedresolution: not a bug
2012-06-28 17:36:45 mrabarnett set messages: +
2012-06-28 17:15:10 serhiy.storchaka set messages: +
2012-06-28 17:13:51 serhiy.storchaka set messages: +
2012-06-15 12:55:05 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2012-06-15 10:41:09 moriyoshi create