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.

classification
Title: re module segfaulting in large regular expression
Type: Stage:
Components: Extension Modules Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: niemeyer Nosy List: edemaine, niemeyer, rhettinger
Priority: high Keywords:

Created on 2004-11-24 03:38 by edemaine, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test2.py edemaine, 2004-11-24 03:38 offending code sample
test2.py edemaine, 2004-11-30 23:57 more offending code sample
sre.patch niemeyer, 2004-12-02 16:20 Patch
Messages (5)
msg23290 - (view) Author: Erik Demaine (edemaine) Date: 2004-11-24 03:38
The attached code worked fine in Python 2.3 and prior,
but broke in a recent version of Python 2.4 (I think
between the alpha and beta, but I'm not sure).  It now
causes a Segmentation fault, at least on my Linux boxes
(2.4.18 and 2.4.22).

For those not looking at the attachment, the code is
essentially:
import re
re.match (...big regular expression..., 'December 20,
1997', re.IGNORECASE)

The code works if the re.IGNORECASE flag is omitted.
I hope I'm not doing anything stupid in installation...
I tried both CVS head and 2.4c1, both with-pyalloc and
without-pyalloc.
msg23291 - (view) Author: Erik Demaine (edemaine) Date: 2004-11-24 03:40
Logged In: YES 
user_id=265183

An update: The same code crashes (general protection fault)
on a vanilla install of 2.4c1 on Windows XP using the MSI
installer.  So I don't think it's my installation.
msg23292 - (view) Author: Erik Demaine (edemaine) Date: 2004-11-30 23:57
Logged In: YES 
user_id=265183

FYI, this bug remains in 2.4final, which is a shame to me
(but probably just a timing mishap), as it makes 2.4
unusable to me.

However, the exact version I attached before does seem to
work on on 2.4final on WindowsXP, but still not on Linux. 
Attached is a version that still fails on 2.4final on all
systems I've tried.  The only difference is using
re.compile(...).match instead of re.match.
msg23293 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-12-01 03:47
Logged In: YES 
user_id=80475

Verified that this segfaults on Py2.4 final but not Py2.3.

msg23294 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2004-12-02 16:20
Logged In: YES 
user_id=7887

I'm really sorry for not fixing this before 2.4 final. The only reason 
it wasn't fixed is because I wasn't aware about it until yesterday. 
 
The problem is fixed in CVS on revision 2.110 of _sre.c. The patch is also 
attached for reference. 
 
Thank you very much for reporting it Erik, and thanks you for pointing the 
bug to me Raymond. 
 
History
Date User Action Args
2022-04-11 14:56:08adminsetgithub: 41222
2004-11-24 03:38:54edemainecreate