Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 53bafd9

Browse files
committed
PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
1 parent 90f8767 commit 53bafd9

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

Mac/Python/macglue.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,24 @@ PyOS_CheckStack()
412412
{
413413
char here;
414414
static char *sentinel = 0;
415+
static PyThreadState *thread_for_sentinel = 0;
415416

416417
if ( sentinel == 0 ) {
417418
sentinel = &here - StackSpace() + MINIMUM_STACK_SIZE;
418419
}
419-
if ( &here < sentinel )
420-
return -1;
420+
if ( thread_for_sentinel == 0 ) {
421+
thread_for_sentinel = PyThreadState_Get();
422+
}
423+
if ( &here < sentinel ) {
424+
if (thread_for_sentinel == PyThreadState_Get()) {
425+
return -1;
426+
#if 0
427+
} else {
428+
/* Else we are unsure... */
429+
fprintf(stderr, "Stackcheck in other thread (was %x now %x)\n", thread_for_sentinel,PyThreadState_Get());
430+
#endif
431+
}
432+
}
421433
return 0;
422434
}
423435
#endif /* USE_STACKCHECK */

0 commit comments

Comments
 (0)