[Python-checkins] python/dist/src/Modules _sre.c,2.97,2.98

aimacintyre@users.sourceforge.net aimacintyre@users.sourceforge.net
Mon, 09 Jun 2003 01:22:14 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv7961

Modified Files:
	_sre.c 
Log Message:
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.


Index: _sre.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_sre.c,v
retrieving revision 2.97
retrieving revision 2.98
diff -C2 -d -r2.97 -r2.98
*** _sre.c	30 Apr 2003 13:09:08 -0000	2.97
--- _sre.c	9 Jun 2003 08:22:11 -0000	2.98
***************
*** 73,83 ****
  #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.
   */
  #define USE_RECURSION_LIMIT 7500
  #else
  #define USE_RECURSION_LIMIT 10000
--- 73,89 ----
  #define USE_RECURSION_LIMIT 7500
  #else
! 
! #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