From 1a44448b24cae0d99aa0556448442dae99604cd7 Mon Sep 17 00:00:00 2001 From: Andrew MacIntyre Date: Mon, 9 Jun 2003 08:22:11 +0000 Subject: Changes to sre.c after the application of patch #726869 have increased stack usage on FreeBSD, requiring the recursion limit to be lowered further. Building with gcc 2.95 (the standard compiler on FreeBSD 4.x) is now also affected. The underlying issue is that FreeBSD's pthreads implementation has a hard-coded 1MB stack size for the initial (or "primary") thread, which can not be changed without rebuilding libc_r. Exhausting this stack results in a bus error. Building without pthreads (configure --without-threads), or linking with the port of the Linux pthreads library (aka Linuxthreads) instead of libc_r, avoids this limitation. On OS/2, only gcc 3.2 is affected and the stack size is controllable, so the special handling has been removed. --- Modules/_sre.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Modules/_sre.c b/Modules/_sre.c index 8203ac8..3f9a2d3 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -72,13 +72,19 @@ static char copyright[] = /* FIXME: maybe the limit should be 40000 / sizeof(void*) ? */ #define USE_RECURSION_LIMIT 7500 #else -#if defined(__GNUC__) && (__GNUC__ > 2) && \ - (defined(__FreeBSD__) || defined(PYOS_OS2)) -/* gcc 3.x, on FreeBSD and OS/2+EMX and at optimisation levels of - * -O3 (autoconf default) and -O2 (EMX port default), generates code - * for _sre that fails for the default recursion limit. + +#if defined(__GNUC__) && defined(WITH_THREAD) && defined(__FreeBSD__) +/* the pthreads library on FreeBSD has a fixed 1MB stack size for the + * initial (or "primary") thread, which is insufficient for the default + * recursion limit. gcc 3.x at the default optimisation + * level (-O3) uses stack space more aggressively than gcc 2.95. */ +#if (__GNUC__ > 2) +#define USE_RECURSION_LIMIT 6500 +#else #define USE_RECURSION_LIMIT 7500 +#endif + #else #define USE_RECURSION_LIMIT 10000 #endif -- cgit v0.12