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: Regular expression tests: SEGV on Mac OS
Type: Stage:
Components: Regular Expressions Versions:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: effbot Nosy List: bbum, brett.cannon, dkwolfe, effbot, gvanrossum, nobody
Priority: high Keywords:

Created on 2001-04-16 21:09 by anonymous, last changed 2022-04-10 16:03 by admin. This issue is now closed.

Messages (8)
msg4287 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-04-16 21:09
The regular expression regression tests 'test_re' 
causes a SEGV failure on Mac OS X version 10.0.1 
when using Python 2.1c2 (and earlier). This is 
caused by the test trying to recurse 50,000 levels 
deep.

Workaround: A workaround is to limit how deep the 
regular expression library can recurse (this is 
already done for Win32). This can be achieved by 
changing file './Modules/_sre.c' using the following 
patch:

--- ./orig/_sre.c   Sun Apr 15 19:00:58 2001
+++ ./new/_sre.c    Mon Apr 16 21:39:29 2001
@@ -75,6 +75,9 @@
    Win64 (MS_WIN64), Linux64 (__LP64__), 
Monterey (64-bit AIX) (_LP64) */
 /* FIXME: maybe the limit should be 40000 / 
sizeof(void*) ? */
 #define USE_RECURSION_LIMIT 7500
+#elif defined(__APPLE_CC__)
+/* Apple 'cc' compiler eg. for Mac OS X */
+#define USE_RECURSION_LIMIT 4000
 #else
 #define USE_RECURSION_LIMIT 10000
 #endif
msg4288 - (view) Author: Dan Wolfe (dkwolfe) Date: 2001-04-17 23:52
Logged In: YES 
user_id=80173

Instead of relying on a compiler variable, we should probably 
set a environment variable as part of the ./configure and use 
that to determine when to reduce the USE_RECURSION_LIMIT.
msg4289 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2001-04-26 22:01
Logged In: YES 
user_id=38376

An alternate (and perhaps better) workaround could be
to increase the stack size on Mac OS X.

But in either case, my plan is to get rid of the recursion
limit in 2.2 (stackless SRE may still run out of memory,
but it shouldn't have to run out of stack).

Cheers /F
msg4290 - (view) Author: Nobody/Anonymous (nobody) Date: 2001-06-02 00:41
Logged In: NO 


>An alternate (and perhaps better) workaround could be
to increase the stack size on Mac OS X.

it's been tried and shot down as a will not fix. :-(

instead of +#elif defined(__APPLE_CC__) perhaps we should use __APPLE__ as per the documentation:

There are two relatively new macros: __APPLE__ and __APPLE_CC__.The former refers to any Apple platform, though at present it is only predefined in Apple's gcc-based Mac OS X and Mac OS X Server compilers. The value of the latter is an integer that corresponds to the version number of the compiler. This should allow one to distinguish, for example, between compilers based on the same version of gcc, but with different bug fixes or features. At present, larger values denote (chronologically) later compilers.

- D

msg4291 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-08-21 03:49
Logged In: YES 
user_id=6380

/F is unavailable, I don't want this to hold up the 2.2a2
release, so I'm lowering the priority because it doesn't
affect Linux or Windows.

(Remember, no bugs/patches with priority >= 7 should be left
when doing a release.)
msg4292 - (view) Author: Nobody/Anonymous (nobody) Date: 2002-04-19 05:16
Logged In: NO 

same problem on 10.1.4

james@i-mech.com

msg4293 - (view) Author: Bill Bumgarner (bbum) Date: 2002-12-04 22:09
Logged In: YES 
user_id=103811

Bad workaround.  A better workaround is to set a reasonable
stacksize limite;  the 'out of the box' stacksize limit is
stupid low.

Try running 'unlimit' before the regression tests -- the
test will pass fine on OS X in that situation.

Limiting the recursion limit on OS X simply because the
[easily changed] out of the box stack size is relatively
small would be a very bad fix indeed.   I have run into a
number of situations where I programatically generate
regular expressions that can be extremely complex.

They explode on OS X without the 'unlimit' and work fine
once the stack has been set to a reasonable maximum size.  
I would be extremely unhappy if those expressions were to
*always* break on OS X due to a change to the internals of
python that assume the stack will always be tiny.
msg4294 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2003-05-16 23:33
Logged In: YES 
user_id=357491

This was fixed a while back in regrtest.py by changing the stack size on OS X 
to a more reasonable size.  Closing this as out of date.
History
Date User Action Args
2022-04-10 16:03:58adminsetgithub: 34348
2001-04-16 21:09:25anonymouscreate