3

I have a tough problem with PySide and Python3. The program crushes randomly because of memory problems. It doesn't throw an unhandled exception or anything, it's the interpreter that dies due to those errors. The program contains two threads. One is for the GUI operations, second for database operations. They communicate using slots/signals and don't really share anything (tasks for the database thread are deepcopied and so are it's results). At first I thought the problems were caused by using cx_Oracle without the threaded parameter, but after adding this parameter changed nothing.

Running the interpreter in gdb gives me those two messages:

*** glibc detected *** /usr/bin/python3.2: free(): invalid pointer: 0x082a02e0 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x75ee2)[0xb7bfdee2]
/usr/bin/python3.2[0x807941b]
/usr/bin/python3.2(PyEval_EvalFrameEx+0x4877)[0x809c7e7]
...
/usr/bin/python3.2(PyEval_CallObjectWithKeywords+0x3e)[0x8097cce]
/usr/bin/python3.2(PyObject_CallObject+0x1f)[0x81418ef]
/usr/lib/i386-linux-gnu/libpyside.cpython-32mu.so.1.1(_ZN6PySide13SignalManager20callPythonMetaMethodERK11QMetaMethodPPvP7_objectb+0x4d)[0xb6b9901d]
/usr/lib/i386-linux-gnu/libpyside.cpython-32mu.so.1.1(_ZN6PySide13SignalManager11qt_metacallEP7QObjectN11QMetaObject4CallEiPPv+0x170)[0xb6b994a0]
...

or

Program received signal SIGSEGV, Segmentation fault.
0x08098746 in PyEval_EvalFrameEx ()
(gdb) info threads
  Id   Target Id         Frame 
  2    Thread 0xb08e6b40 (LWP 14528) "python3.2" 0xb7fdd424 in __kernel_vsyscall ()
* 1    Thread 0xb7b866c0 (LWP 14527) "python3.2" 0x08098746 in PyEval_EvalFrameEx ()

(gdb) thread 2
[Switching to thread 2 (Thread 0xb08e6b40 (LWP 14528))]
#0  0xb7fdd424 in __kernel_vsyscall ()
...

#35 0x08097cce in PyEval_CallObjectWithKeywords ()
#36 0x081418ef in PyObject_CallObject ()
#37 0xb6b9901d in PySide::SignalManager::callPythonMetaMethod(QMetaMethod const&, void**, _object*, bool) () from /usr/lib/i386-linux-gnu/libpyside.cpython-32mu.so.1.1
#38 0xb6b994a0 in PySide::SignalManager::qt_metacall(QObject*, QMetaObject::Call, int, void**) () from /usr/lib/i386-linux-gnu/libpyside.cpython-32mu.so.1.1

I can see that it allways happens somewhere inside Qt library, but there is no way to reproduce this crash on demand. I have to run the program, use it for some time and then it crashes.

Because of this behavior I don't really know what to look for, how to debug. I tried disabling garbage collector with gc.disable() at the beginning of the program, but it didn't change anything. I read that Qt has it's own memory management system. Is it possible that it's its fault?

Please at least give me some ideas that to look for in my code.

4

0 回答 0