summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2019-08-01 07:43:07 +0200
committerGitHub <noreply@github.com>2019-08-01 07:43:07 +0200
commit1a057bab0f18d6ad843ce321d1d77a4819497ae4 (patch)
tree4018de28edc28e3bcd8564de6d790b7ad4384bbb
parented5e8e06cbf766e89d6c58a882ee024abb5b2ed7 (diff)
downloadcpython-git-1a057bab0f18d6ad843ce321d1d77a4819497ae4.tar.gz
bpo-18049: Sync thread stack size to main thread size on macOS (GH-14748)
This changeset increases the default size of the stack for threads on macOS to the size of the stack of the main thread and reenables the relevant recursion test.
-rw-r--r--Lib/test/test_threading.py2
-rw-r--r--Misc/NEWS.d/next/macOS/2019-07-13-15-58-18.bpo-18049.MklhQQ.rst3
-rw-r--r--Python/thread_pthread.h3
-rwxr-xr-xconfigure2
-rw-r--r--configure.ac2
5 files changed, 9 insertions, 3 deletions
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index a99b8eca2b..1466d25e94 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -1057,8 +1057,6 @@ class ThreadingExceptionTests(BaseTestCase):
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
diff --git a/Misc/NEWS.d/next/macOS/2019-07-13-15-58-18.bpo-18049.MklhQQ.rst b/Misc/NEWS.d/next/macOS/2019-07-13-15-58-18.bpo-18049.MklhQQ.rst
new file mode 100644
index 0000000000..5af07cdb41
--- /dev/null
+++ b/Misc/NEWS.d/next/macOS/2019-07-13-15-58-18.bpo-18049.MklhQQ.rst
@@ -0,0 +1,3 @@
+Increase the default stack size of threads from 5MB to 16MB on macOS, to
+match the stack size of the main thread. This avoids crashes on deep recursion
+in threads.
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index a36d16c19e..994e35b2cc 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -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
diff --git a/configure b/configure
index 4cea98e365..bffb849b79 100755
--- a/configure
+++ b/configure
@@ -9542,6 +9542,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"
diff --git a/configure.ac b/configure.ac
index b9759e12f8..8566d43384 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2694,6 +2694,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"