A trace using gdb on karmic. Application (patched version of apport-kde) crashes on exit. The run and exit code: # Don't exec_() here. There is no main interface and the dialogs are # exec_()ed independently. ret = int(UserInterface.run_argv()) print "run_argv returned" KApplication.exit(ret) print "kapplication.exit returned" sys.exit(ret) The output and trace: run_argv returned kapplication.exit returned Program received signal SIGSEGV, Segmentation fault. 0x052c1ce2 in ~QX11WindowSurface (this=0x8ad3e20, __in_chrg=) at painting/qwindowsurface_x11.cpp:84 84 painting/qwindowsurface_x11.cpp: No such file or directory. in painting/qwindowsurface_x11.cpp Current language: auto; currently c++ (gdb) backtrace #0 0x052c1ce2 in ~QX11WindowSurface (this=0x8ad3e20, __in_chrg=) at painting/qwindowsurface_x11.cpp:84 #1 0x052ba946 in ~QWidgetBackingStore (this=0x8ad3df0, __in_chrg=) at painting/qbackingstore.cpp:829 #2 0x0511c944 in QWidgetPrivate::deleteExtra (this=0x8aadf30) at kernel/qwidget.cpp:1503 #3 0x0511d0e5 in ~QWidgetPrivate (this=0x8aadf30, __in_chrg=) at kernel/qwidget.cpp:227 #4 0x055a6189 in ~QDialogPrivate (this=0x8aadf30, __in_chrg=) at ../../include/QtGui/private/../../../src/gui/dialogs/qdialog_p.h:67 #5 0x005de85a in ~QObject (this=0x8b825d8, __in_chrg=) at kernel/qobject.cpp:857 #6 0x0512294f in ~QWidget (this=0x8b825d8, __in_chrg=) at kernel/qwidget.cpp:1380 #7 0x055bde44 in ~QDialog (this=0x8b825d8, __in_chrg=) at dialogs/qdialog.cpp:298 #8 0x01278653 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtGui.so #9 0x012177a6 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtGui.so #10 0x012177e9 in ?? () from /usr/lib/pymodules/python2.6/PyQt4/QtGui.so #11 0x0038d588 in ?? () from /usr/lib/pymodules/python2.6/sip.so #12 0x0038d5c1 in ?? () from /usr/lib/pymodules/python2.6/sip.so #13 0x080a8e13 in subtype_dealloc (self=0x8baf4ac) at ../Objects/typeobject.c:1024 #14 0x0808e574 in dict_dealloc (mp=0x88464f4) at ../Objects/dictobject.c:911 #15 0x0806a3eb in instance_dealloc (inst=0x8cc1a8c) at ../Objects/classobject.c:668 #16 0x0808ce59 in insertdict (mp=0xb7fd61c4, key=0xb7ebb4a8, hash=-414803461, value=0x8245f58) at ../Objects/dictobject.c:459 #17 0x0808f2b7 in PyDict_SetItem (op=0xb7fd61c4, key=0xb7ebb4a8, value=0x8245f58) at ../Objects/dictobject.c:701 #18 0x08090c13 in _PyModule_Clear (m=0xb7fa411c) at ../Objects/moduleobject.c:138 #19 0x080ed7a5 in PyImport_Cleanup () at ../Python/import.c:444 #20 0x080fa0d5 in Py_Finalize () at ../Python/pythonrun.c:434 #21 0x080f9b7f in Py_Exit () at ../Python/pythonrun.c:1714 #22 handle_system_exit () at ../Python/pythonrun.c:1116 #23 0x080f9d6d in PyErr_PrintEx (set_sys_last_vars=1) at ../Python/pythonrun.c:1126 #24 0x080f9fa2 in PyErr_Print () at ../Python/pythonrun.c:1035 #25 0x080faacb in PyRun_SimpleFileExFlags (fp=0xbffffa8b, filename=0xbffffa8b "/usr/share/apport/apport-kde", closeit=1, flags=0xbffff80c) at ../Python/pythonrun.c:935 #26 0x0805c898 in Py_Main (argc=3, argv=0xbffff8f4) at ../Modules/main.c:599 #27 0x0805baab in main (argc=3, argv=0xbffff8f4) at ../Modules/python.c:23 The behavior is the same with or without the KApplication.exit()