This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Michael.Felt
Recipients Michael.Felt, matrixise, miss-islington, ned.deily, ronaldoussoren, steve.dower, vstinner
Date 2019-08-02.10:17:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
On 02/08/2019 11:57, Michael Felt wrote:
> On 02/08/2019 11:48, Ronald Oussoren wrote:
>> Ronald Oussoren <> added the comment:
>> That code is only called if THREAD_STACK_SIZE is defined. The block I mention defines it for macOS and FreeBSD, but not for other platforms. I therefore expect that this code is not used on AIX (which would be easy enough to verify by adding an #error to the block you mention.
> Should have been watching mail - I'll look at this asap.

Actually, it is defined for "most" platforms...

xlc_r -c  -DNDEBUG -O -I/opt/include -O2 -qmaxmem=-1    
-I../git/python3-3.9/Include/internal -IObjects -IInclude -IPython -I.
-I../git/python3-3.9/Include -I/opt/include   -DPy_BUILD_CORE -o
Python/thread.o ../git/python3-3.9/Python/thread.c
"../git/python3-3.9/Python/thread_pthread.h", line 255.2: 1506-205 (S)
#error "Not expected"
make: *** [Makefile:1706: Python/thread.o] Error 1

At the top of the file:

/* The POSIX spec requires that use of pthread_attr_setstacksize
   be conditional on _POSIX_THREAD_ATTR_STACKSIZE being defined. */
#define THREAD_STACK_SIZE       0       /* use default stack size */

/* The default stack size for new threads on OSX and BSD is small enough
 * we'll get hard crashes instead of 'maximum recursion depth exceeded'
 * exceptions.
 * The default stack sizes below are the empirically determined minimal
 * sizes where a simple recursive function doesn't cause a hard crash.

So, the block is executed - but the size is 0 aka default.

As a first attempt - I'll take the FreeBSD size going:

michael@x071:[/data/prj/python/git/python3-3.9]git diff
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index 994e35b..83b7e77 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -47,6 +47,10 @@
 #define THREAD_STACK_SIZE       0x400000
+#if defined(_AIX) && defined(THREAD_STACK_SIZE) && THREAD_STACK_SIZE == 0
+#define THREAD_STACK_SIZE       0x400000
 /* for safety, ensure a viable minimum stacksize */
 #define THREAD_STACK_MIN        0x8000  /* 32 KiB */

And with this - the test passes. :)
Date User Action Args
2019-08-02 10:17:47Michael.Feltsetrecipients: + Michael.Felt, ronaldoussoren, vstinner, ned.deily, steve.dower, matrixise, miss-islington
2019-08-02 10:17:47Michael.Feltlinkissue18049 messages
2019-08-02 10:17:47Michael.Feltcreate