Skip to content

Commit 8464292

Browse files
author
jackjansen
committed
GUSI on the Mac creates threads with a default stack size of 20KB, which is not enough for Python. Increased the stacksize to a (somewhat arbitrary) 64KB.
git-svn-id: http://svn.python.org/projects/python/trunk@22794 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 0702710 commit 8464292

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

Python/thread_pthread.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848

4949
#endif
5050

51+
#ifdef USE_GUSI
52+
/* The Macintosh GUSI I/O library sets the stackspace to
53+
** 20KB, much too low. We up it to 64K.
54+
*/
55+
#define THREAD_STACK_SIZE 0x10000
56+
#endif
57+
5158

5259
/* set default attribute object for different versions */
5360

@@ -128,10 +135,17 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
128135
{
129136
pthread_t th;
130137
int success;
138+
#ifdef THREAD_STACK_SIZE
139+
pthread_attr_t attrs;
140+
#endif
131141
dprintf(("PyThread_start_new_thread called\n"));
132142
if (!initialized)
133143
PyThread_init_thread();
134144

145+
#ifdef THREAD_STACK_SIZE
146+
pthread_attr_init(&attrs);
147+
pthread_attr_setstacksize(&attrs, THREAD_STACK_SIZE);
148+
#endif
135149
success = pthread_create(&th,
136150
#if defined(PY_PTHREAD_D4)
137151
pthread_attr_default,
@@ -146,12 +160,18 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
146160
func,
147161
arg
148162
#elif defined(PY_PTHREAD_STD)
163+
#ifdef THREAD_STACK_SIZE
164+
&attrs,
165+
#else
149166
(pthread_attr_t*)NULL,
167+
#endif
150168
(void* (*)(void *))func,
151169
(void *)arg
152170
#endif
153171
);
154-
172+
#ifdef THREAD_STACK_SIZE
173+
pthread_attr_destroy(&attrs);
174+
#endif
155175
if (success == 0) {
156176
#if defined(PY_PTHREAD_D4) || defined(PY_PTHREAD_D6) || defined(PY_PTHREAD_D7)
157177
pthread_detach(&th);

0 commit comments

Comments
 (0)