[Kde-bindings] [Bug 219787] krosspython: crash when PyQt signal is connected to C++ method that calls a function in the script

Daniel Calviño Sánchez danxuliu at gmail.com
Wed Dec 23 06:29:37 UTC 2009


https://bugs.kde.org/show_bug.cgi?id=219787





--- Comment #2 from Daniel Calviño Sánchez <danxuliu gmail com>  2009-12-23 07:29:36 ---
Created an attachment (id=39278)
 --> (http://bugs.kde.org/attachment.cgi?id=39278)
Patch for pythonscript.cpp with a workaround to the bug

Although the crash itself happens in Python libraries, the backtrace goes
through pythonscript.cpp before diving into Python libraries. I take a look to
the las Kross executed method (PythonScript::callFunction(const QString& name,
const QVariantList& args)) and found "//TODO do we need to acquire interpreter
lock here?". So I tried to lock the interpreter where the crash happened (not
in the whole method, as the TODO suggested).

I wrapped PyErr_Clear() with a lock, and then the method was executed further
before crashing again. So then I locked the next place where it happened
(Py::Object pyresult =
funcobject.apply(PythonType<QVariantList,Py::Tuple>::toPyObject(args));), and
then again in QVariant result = PythonType<QVariant>::toVariant(pyresult);
(which uses the same lock as the previous sentence because they were one after
the other).

After locking the interpreter in those places, all was fine. No more crashes,
and the script behaved as expected. Note, however, that some locks may be
needed in the catch clause (I haven't tested it with code that launched
exceptions).

And also, please take into account that I have no true idea of what I did. I
mean, I locked the interpreter using the code found somewhere else in
pythonscript.cpp, and I locked it because there was a TODO suggesting it. But I
don't know if it is the best fix, or if it is a fix at all and not just a
workaround. I only know that locking the interpreter no crash happens ;)

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Kde-bindings mailing list