File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,6 +100,16 @@ extern pascal unsigned char *PLstrrchr(unsigned char *, unsigned char);
100100#endif
101101#endif
102102
103+ #if TARGET_API_MAC_CARBON
104+ /*
105+ ** On MacOSX StackSpace() lies: it gives the distance from heap end to stack pointer,
106+ ** but the stack cannot grow that far due to rlimit values. We cannot get at this value
107+ ** from Carbon, so we set a maximum to the stack here that is based on the default
108+ ** stack limit of 512K.
109+ */
110+ #define MAXIMUM_STACK_SIZE (256*1024)
111+ #endif
112+
103113/*
104114** We have to be careful, since we can't handle
105115** things like updates (and they'll keep coming back if we don't
@@ -429,8 +439,15 @@ PyOS_CheckStack()
429439 static char * sentinel = 0 ;
430440 static PyThreadState * thread_for_sentinel = 0 ;
431441
432- if ( sentinel == 0 ) {
433- sentinel = & here - StackSpace () + MINIMUM_STACK_SIZE ;
442+ if ( sentinel == 0 ) {
443+ unsigned long stackspace = StackSpace ();
444+
445+ #ifdef MAXIMUM_STACK_SIZE
446+ /* See the comment at the definition */
447+ if ( stackspace > MAXIMUM_STACK_SIZE )
448+ stackspace = MAXIMUM_STACK_SIZE ;
449+ #endif
450+ sentinel = & here - stackspace + MINIMUM_STACK_SIZE ;
434451 }
435452 if ( thread_for_sentinel == 0 ) {
436453 thread_for_sentinel = PyThreadState_Get ();
You can’t perform that action at this time.
0 commit comments