Skip to content

Commit bde3873

Browse files
committed
Backport 2.3 FreeBSD recursion_limit settings. Fixes #553736.
1 parent 22eb8bc commit bde3873

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Modules/_sre.c

+14
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,24 @@ static char copyright[] =
7575
Win64 (MS_WIN64), Linux64 (__LP64__), Monterey (64-bit AIX) (_LP64) */
7676
/* FIXME: maybe the limit should be 40000 / sizeof(void*) ? */
7777
#define USE_RECURSION_LIMIT 7500
78+
#else
79+
#if defined(__GNUC__) && defined(WITH_THREAD) && defined(__FreeBSD__)
80+
/* the pthreads library on FreeBSD has a fixed 1MB stack size for the
81+
* initial (or "primary") thread, which is insufficient for the default
82+
* recursion limit. gcc 3.x at the default optimisation
83+
* level (-O3) uses stack space more aggressively than gcc 2.95.
84+
*/
85+
#if (__GNUC__ > 2)
86+
#define USE_RECURSION_LIMIT 6500
87+
#else
88+
#define USE_RECURSION_LIMIT 7500
89+
#endif
90+
7891
#else
7992
#define USE_RECURSION_LIMIT 10000
8093
#endif
8194
#endif
95+
#endif
8296

8397
/* enables fast searching */
8498
#define USE_FAST_SEARCH

0 commit comments

Comments
 (0)