Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Respond to Ronald's review
  • Loading branch information
ambv committed Aug 28, 2021
commit 7044e8f31fe47688ed873a3bbd66e85dc5275d33
13 changes: 6 additions & 7 deletions Python/thread_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,17 @@
#define THREAD_STACK_SIZE 0 /* use default stack size */
#endif

/* The default stack size for new threads on OSX and BSD is small enough that
/* The default stack size for new threads on BSD is small enough that
* we'll get hard crashes instead of 'maximum recursion depth exceeded'
* exceptions.
*
* The default stack sizes below are the empirically determined minimal stack
* The default stack size below is the empirically determined minimal stack
* sizes where a simple recursive function doesn't cause a hard crash.
*
* For macOS the value of THREAD_STACK_SIZE is determined in configure.ac
* as it also depends on the other configure options like chosen sanitizer
* runtimes.
*/
#if defined(__APPLE__) && defined(THREAD_STACK_SIZE) && THREAD_STACK_SIZE == 0
#undef THREAD_STACK_SIZE
/* Note: This matches the value of -Wl,-stack_size in configure.ac */
#define THREAD_STACK_SIZE 0x1000000
#endif
#if defined(__FreeBSD__) && defined(THREAD_STACK_SIZE) && THREAD_STACK_SIZE == 0
#undef THREAD_STACK_SIZE
#define THREAD_STACK_SIZE 0x400000
Expand Down
12 changes: 6 additions & 6 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -9871,20 +9871,20 @@ then
# Issue #18075: the default maximum stack size (8MBytes) is too
# small for the default recursion limit. Increase the stack size
# to ensure that tests don't crash
# Note: This matches the value of THREAD_STACK_SIZE in
# thread_pthread.h
stack_size="1000000"
stack_size="1000000" # 16 MB
if test "$with_ubsan" == "yes"
then
# Undefined behavior sanitizer requires an even deeper stack
stack_size="4000000"
stack_size="4000000" # 64 MB
fi

LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED"


cat >>confdefs.h <<_ACEOF
#define THREAD_STACK_SIZE 0x$stack_size
_ACEOF

fi
LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED"

if test "$enable_framework"
then
Expand Down
14 changes: 7 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2839,19 +2839,19 @@ then
# Issue #18075: the default maximum stack size (8MBytes) is too
# small for the default recursion limit. Increase the stack size
# to ensure that tests don't crash
# Note: This matches the value of THREAD_STACK_SIZE in
# thread_pthread.h
stack_size="1000000"
stack_size="1000000" # 16 MB
if test "$with_ubsan" == "yes"
then
# Undefined behavior sanitizer requires an even deeper stack
stack_size="4000000"
AC_DEFINE_UNQUOTED(THREAD_STACK_SIZE,
0x$stack_size,
[Custom thread stack size to fit the undefined behavior sanitizer runtime.])
stack_size="4000000" # 64 MB
fi

LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED"

AC_DEFINE_UNQUOTED(THREAD_STACK_SIZE,
0x$stack_size,
[Custom thread stack size depending on chosen sanitizer runtimes.])

if test "$enable_framework"
then
LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
Expand Down
3 changes: 1 addition & 2 deletions pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1509,8 +1509,7 @@
(which you can't on SCO ODT 3.0). */
#undef SYS_SELECT_WITH_SYS_TIME

/* Custom thread stack size to fit the undefined behavior sanitizer runtime.
*/
/* Custom thread stack size depending on chosen sanitizer runtimes. */
#undef THREAD_STACK_SIZE

/* Library needed by timemodule.c: librt may be needed for clock_gettime() */
Expand Down