summaryrefslogtreecommitdiffstats
path: root/Mac/Python
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2001-02-02 22:40:28 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2001-02-02 22:40:28 (GMT)
commit340eb88fa886d81dc3d0153bd96a4690962d91fa (patch)
tree8bac7e2880a0ebfc8ed21194ff1546c3dd4846db /Mac/Python
parentf8cdb5c56f6a14b62ffb3201de45f586fe3a6500 (diff)
downloadcpython-340eb88fa886d81dc3d0153bd96a4690962d91fa.zip
cpython-340eb88fa886d81dc3d0153bd96a4690962d91fa.tar.gz
cpython-340eb88fa886d81dc3d0153bd96a4690962d91fa.tar.bz2
On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Diffstat (limited to 'Mac/Python')
-rw-r--r--Mac/Python/macglue.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/Mac/Python/macglue.c b/Mac/Python/macglue.c
index 8fdbc23..ade635e 100644
--- a/Mac/Python/macglue.c
+++ b/Mac/Python/macglue.c
@@ -100,6 +100,16 @@ extern pascal unsigned char *PLstrrchr(unsigned char *, unsigned char);
#endif
#endif
+#if TARGET_API_MAC_CARBON
+/*
+** On MacOSX StackSpace() lies: it gives the distance from heap end to stack pointer,
+** but the stack cannot grow that far due to rlimit values. We cannot get at this value
+** from Carbon, so we set a maximum to the stack here that is based on the default
+** stack limit of 512K.
+*/
+#define MAXIMUM_STACK_SIZE (256*1024)
+#endif
+
/*
** We have to be careful, since we can't handle
** things like updates (and they'll keep coming back if we don't
@@ -429,8 +439,15 @@ PyOS_CheckStack()
static char *sentinel = 0;
static PyThreadState *thread_for_sentinel = 0;
- if ( sentinel == 0 ) {
- sentinel = &here - StackSpace() + MINIMUM_STACK_SIZE;
+ if ( sentinel == 0 ) {
+ unsigned long stackspace = StackSpace();
+
+#ifdef MAXIMUM_STACK_SIZE
+ /* See the comment at the definition */
+ if ( stackspace > MAXIMUM_STACK_SIZE )
+ stackspace = MAXIMUM_STACK_SIZE;
+#endif
+ sentinel = &here - stackspace + MINIMUM_STACK_SIZE;
}
if ( thread_for_sentinel == 0 ) {
thread_for_sentinel = PyThreadState_Get();