Logged In: YES
user_id=11105
Sorry, that's because I'm still confused about thread
states, and I think the experts ;-) should sort this out.
No, I'm not claiming that the GIL does not need to be held,
I'm claiming that this is not sufficient: *in addition* the
current threadstate must not be NULL.
To quote from the mentioned posts:
I was doing this:
pts = PyThreadState_Swap(NULL);
PyThreadState_Clear(pts);
PyThreadState_Delete(pts);
PyEval_ReleaseLock();
and got a crash in PyThreadState_Clear(). If I understand
the current docs correctly, this should be allowed, so (my
conclusion) the docs are wrong.
I had to change the code in this way to avoid the crashes:
pts = PyThreadState_Get();
PyThreadState_Clear(pts);
pts = PyThreadState_Swap(NULL);
PyThreadState_Delete(pts);
PyEval_ReleaseLock();
|