Correction:

this was too quick. Shiboken does not directly use the threadstate
but only a reference, which is probably ok.A typical mis-reading
that always hits me with C++.

Will investigate further, why Stackless Python causes crashes with PySide.

Update:
It is pretty likely that there is a problem with extra data fields behind
the type object structure, which is used by both pyside and stackless.

from basewrapper.h :

/// PyTypeObject extended with C++ multiple inheritance information.
struct LIBSHIBOKEN_API SbkObjectType
{
    PyHeapTypeObject super;
    SbkObjectTypePrivate* d;
};

This overlaps with the Stackless version of PyHealTypeObject,
which is compatible but larger than CPython's!
At the end of the stackless heaptype lives a bytemap:

slp_methodflagsslpflags;

which misinterprets the field

    SbkObjectTypePrivate* d;


cheers - chris


On 12/8/12 4:45 AM, Christian Tismer wrote:
Resent with a clearer subject line

This comes from the stackless mailing list.

PySide directly uses the threadstate structure of Cpython, which
is a protocol violation. See below...

Am 08.12.2012 um 01:49 schrieb Christian Tismer <[email protected]>:

Hi friends,

this evening, I looked a bit into shiboken, the module that is used
for creating python interfaces for PySide, and now I'm
pretty confident that I found a reason that is creating some issues.

libshiboken has an include file called sbkpython.h, and this includes
python.h from the installed python.

And now we come to the interesting stuff:

There is threadstatesaver.h and threadstatesaver.cpp !
The latter has code like:

void ThreadStateSaver::save()
{
     if (PyEval_ThreadsInitialized())
         m_threadState = PyEval_SaveThread();
}

But that code uses the threadstate definition from the cpython threadstate
module, instead of the different (at least larger) structure in stackless
threadstate. ;-)

IOW., things *might* work if pyside is built against stackless python
instead of CPython.

Today I looked at a simple PySide script and a larger one - they both used
multiple threads for startup. No idea if this code is involved there,
python did not use threads, but I could imagine that is at least a time
bomb.


Now, the question is: how to resolve this?
------------------------------------------

One way that needs testing is if PySide works ok on stackless
when built from source. I could write an installer for this case.

The other question is: can we change stackless in a way that works
with PySide compiled for CPython?

That would mean: tstate must stay completely unchanged in size.
I guess the extra info that we use would neet to be put into a
different structure, and the linkage back to tstate is a little trick,
at least.

Another way would be to add a patch to libshiboken, that checks the
real size of tstate dynamically. This would be an easier patch, although
I think that at the moment it is not so easy to get anything into pyside,
quickly.

I would like to get your opinion.
And I definately want to make stackless work with pyside.

The source code can be inspected here:

http://qt.gitorious.org/pyside/shiboken/trees/master

cheers - chris

[cross-posting to the pyside list]

--
Christian Tismer             :^)   <mailto:[email protected]>
Software Consulting          :     Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121     :    *Starship* http://starship.python.net/
14482 Potsdam                :     PGP key -> http://pgp.uni-mainz.de
phone +49 173 24 18 776  fax +49 (30) 700143-0023
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
       whom do you want to sponsor today?   http://www.stackless.com/

_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside


--
Christian Tismer             :^)   <mailto:[email protected]>
Software Consulting          :     Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121     :    *Starship* http://starship.python.net/
14482 Potsdam                :     PGP key -> http://pgp.uni-mainz.de
phone +49 173 24 18 776  fax +49 (30) 700143-0023
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/

_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless

Reply via email to