Skip to content

bpo-18049: Sync thread stack size to main thread size on macOS #14748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions Lib/test/test_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,8 +1057,6 @@ def test_releasing_unacquired_lock(self):
lock = threading.Lock()
self.assertRaises(RuntimeError, lock.release)

@unittest.skipUnless(sys.platform == 'darwin' and test.support.python_is_optimized(),
'test macosx problem')
def test_recursion_limit(self):
# Issue 9670
# test that excessive recursion within a non-main thread causes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Increase the default stack size of threads from 5MB to 16MB on macOS, to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick:

Suggested change
Increase the default stack size of threads from 5MB to 16MB on macOS, to
Increase the default stack size of threads from 5 MiB to 16 MiB on macOS, to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is MiB something we use elsewhere?

I'm probably old, but don't particularly like the MiB vs. MB distinction as it is often clear from the context what's meant.

match the stack size of the main thread. This avoids crashes on deep recursion
in threads.
3 changes: 2 additions & 1 deletion Python/thread_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
*/
#if defined(__APPLE__) && defined(THREAD_STACK_SIZE) && THREAD_STACK_SIZE == 0
#undef THREAD_STACK_SIZE
#define THREAD_STACK_SIZE 0x500000
/* 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
Expand Down
2 changes: 2 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -9528,6 +9528,8 @@ 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
LINKFORSHARED="-Wl,-stack_size,1000000 $LINKFORSHARED"

if test "$enable_framework"
Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2686,6 +2686,8 @@ 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
LINKFORSHARED="-Wl,-stack_size,1000000 $LINKFORSHARED"

if test "$enable_framework"
Expand Down