mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
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.
This commit is contained in:
parent
90f876798f
commit
53bafd97d0
1 changed files with 14 additions and 2 deletions
|
@ -412,12 +412,24 @@ PyOS_CheckStack()
|
|||
{
|
||||
char here;
|
||||
static char *sentinel = 0;
|
||||
static PyThreadState *thread_for_sentinel = 0;
|
||||
|
||||
if ( sentinel == 0 ) {
|
||||
sentinel = &here - StackSpace() + MINIMUM_STACK_SIZE;
|
||||
}
|
||||
if ( &here < sentinel )
|
||||
return -1;
|
||||
if ( thread_for_sentinel == 0 ) {
|
||||
thread_for_sentinel = PyThreadState_Get();
|
||||
}
|
||||
if ( &here < sentinel ) {
|
||||
if (thread_for_sentinel == PyThreadState_Get()) {
|
||||
return -1;
|
||||
#if 0
|
||||
} else {
|
||||
/* Else we are unsure... */
|
||||
fprintf(stderr, "Stackcheck in other thread (was %x now %x)\n", thread_for_sentinel,PyThreadState_Get());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* USE_STACKCHECK */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue