[issue1758146] Crash in PyObject_Malloc
Franco DiRosa
report at bugs.python.org
Wed Jul 9 06:21:21 CEST 2008
Franco DiRosa <fdirosa at stny.rr.com> added the comment:
Thanks Adam
but....
I'm still confused because...
There is a new rule in version 2.3.5. Which is one interpreter with many
thread states are supported for the GIL functions. So this code breaks that
rule since this if statement is checking if the interpreters are different
for the current GIL state and the new ts which it can't be (i.e.
unsupported). See this email that points to the python documentation for
2.3.5 regarding this "new" rule...
http://mail.python.org/pipermail/python-dev/2005-May/053840.html
Here is the extract of the email pertaining to this issue...
The documentation (http://docs.python.org/api/threads.html) states
"Note that the PyGILState_*() functions assume there is only one
global interpreter (created automatically by Py_Initialize()). Python
still supports the creation of additional interpreters (using
Py_NewInterpreter()), but mixing multiple interpreters and the
PyGILState_*() API is unsupported. ", so it looks like that using the
PyGilState_XXX functions in the core threadmodule.c means the
Py_NewInterpreter() call (i.e. multiple interpreters) is no longer
supported when threads are involved.
So regardless if we use the GIL functions or the lower level functions it
all eventually boils down to this Swap function which has this condition
that doesn't match what the documentation is stating. So which way is it?
Can't have it both ways.
It seems since 2.3.5 they don't want you to use multiple interpreters is my
guess when threading is involved.
- Franco
----- Original Message -----
From: "Adam Olsen" <report at bugs.python.org>
To: <fdirosa at stny.rr.com>
Sent: Tuesday, July 08, 2008 6:25 PM
Subject: [issue1758146] Crash in PyObject_Malloc
Adam Olsen <rhamph at gmail.com> added the comment:
Franco, you need to look at the line above that check:
PyThreadState *check = PyGILState_GetThisThreadState();
if (check && check->interp == newts->interp && check != newts)
Py_FatalError("Invalid thread state for this thread");
PyGILState_GetThisThreadState returns the original tstate *for that
thread*. What it's asserting is that, if there's a second tstate *in
that thread*, it must be in a different subinterpreter.
It doesn't prevent your second and third tstate from sharing the same
subinterpreter, but it probably should, as this check implies it's an
invariant.
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1758146>
_______________________________________
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1758146>
_______________________________________
More information about the Python-bugs-list
mailing list