简体   繁体   中英

python: Segmentation fault (core dumped)

I have written a Qt application in python using PySide library. When i close it i get Segmentation fault (core dumped)

Backtrace using gdb:

(gdb) backtrace 
#0  0x00007ffff5d19c40 in QObject::staticMetaObject () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#1  0x00007ffff64c4bce in PySide::SignalManager::clear() () from /usr/lib/x86_64-linux-gnu/libpyside-python2.7.so.1.2
#2  0x00007ffff64d1f95 in PySide::destroyQCoreApplication() () from /usr/lib/x86_64-linux-gnu/libpyside-python2.7.so.1.2
#3  0x00007ffff64d2981 in PySide::runCleanupFunctions() () from /usr/lib/x86_64-linux-gnu/libpyside-python2.7.so.1.2
#4  0x00007ffff683ecc5 in ?? () from /usr/lib/python2.7/dist-packages/PySide/QtCore.so
#5  0x000000000052f936 in PyEval_EvalFrameEx ()
#6  0x000000000056d0aa in ?? ()
#7  0x00000000004da29f in PyEval_CallObjectWithKeywords ()
#8  0x000000000042fa19 in Py_Finalize ()
#9  0x000000000042fb7c in Py_Exit ()
#10 0x000000000042fcb9 in ?? ()
#11 0x000000000042ec32 in PyErr_PrintEx ()
#12 0x000000000042f042 in ?? ()
#13 0x000000000046aa09 in Py_Main ()
#14 0x00007ffff7817ec5 in __libc_start_main (main=0x46ac3f <main>, argc=2, argv=0x7fffffffdf58, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fffffffdf48) at libc-start.c:287
#15 0x000000000057497e in _start ()

Version:

QMake version 3.0
Using Qt version 5.2.1 in /usr/lib/x86_64-linux-gnu
Python 2.7.6
Ubuntu 14.04

How i can solve this?

If this question is still up-to-date, I had the same Problem and solved it today. In my case it was a problem by calling

destroy()

method of my widget directly. Since I had some threads left open it ran into a segfault. As I read right now it is a better practice to emit the close event.

I did now also override the closeEvt() method and checked there if the there is stuff to do before closing the app

##
#  Closes the application
#  ...
def closeEvent(self, event):
    if self.canClose() # Exit the application
        event.accept() 
        logging.debug("Closed App clean")
    else:
        # Do stuff to close the application cleanly
        if canCloseNow:
            event.accept()
        else: 
            # Give user feedbackstuff like opening a save dialog 
            # or some other stuff...
            event.ignore()

I am aware that most possibly there are much more elegant procedures to do this but for me it worked quite well...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM