Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-585

Segfault due to reference counting when exiting Jupyter QtConsole

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Fixed
    • Affects Version/s: 5.6, 5.9
    • Fix Version/s: 5.9
    • Component/s: PySide
    • Labels:
      None
    • Environment:
      Qt 5.9.1, PySide2 5.9 branch (as of ref {{fbb90fbf357f5632b3c87c8766e6d56c48f6a45a}}), Python 3.6.2, macOS 10.13.2, Jupyter QtConsole 4.3.1
    • Commits:
      b811c874dedd14fd8b072bc73761d39255216073

      Description

      If you launch Jupyter QtConsole using PySide2 as its Qt bindings, and exit it (even if you immediately close it after doing nothing) you will get this error when closing the window:

      $ jupyter-qtconsole
      Fatal Python error: deallocating None
      
      Current thread 0x0000000101896340 (most recent call first):
      Abort trap: 6
      

      This is probably due to reference counting not being right somewhere - not quite sure where this is happening yet though.

      Minimal example:

      from PySide2 import QtWidgets
      
      app_instance = QtWidgets.QApplication([])
      # If this is commented, application doesn't crash on exit anymore.
      app_instance2 = app_instance
      
      w = QtWidgets.QMainWindow()
      w.setWindowTitle('Hello World!')
      w.resize(250, 150)
      w.show()
      app_instance.exec_()
      

      Stacktrace:

      frame #0: 0x00007fffcb80ad42 libsystem_kernel.dylib`__pthread_kill + 10
          frame #1: 0x00007fffcb8f8457 libsystem_pthread.dylib`pthread_kill + 90
          frame #2: 0x00007fffcb770420 libsystem_c.dylib`abort + 129
          frame #3: libpython3.5m.dylib`Py_FatalError(msg="deallocating None") at pylifecycle.c:1385
          frame #4: libpython3.5m.dylib`none_dealloc(ignore=0x000000010165ca38) at object.c:1372
          frame #5: libpython3.5m.dylib`insertdict(mp=0x000000010078dcc8, key=0x0000000106b053e8, hash=-5214649808865345009, value=0x00000001003212f8) at dictobject.c:809
          frame #6: libpython3.5m.dylib`PyDict_SetItem(op=0x000000010078dcc8, key=0x0000000106b053e8, value=0x00000001003212f8) at dictobject.c:1228
          frame #7: libpython3.5m.dylib`_PyModule_ClearDict(d=0x000000010078dcc8) at moduleobject.c:593
          frame #8: libpython3.5m.dylib`_PyModule_Clear(m=0x000000010077df48) at moduleobject.c:544
          frame #9: libpython3.5m.dylib`PyImport_Cleanup at import.c:460
          frame #10: libpython3.5m.dylib`Py_Finalize at pylifecycle.c:576
          frame #11: libpython3.5m.dylib`Py_Main(argc=2, argv=0x0000000100502b70) at main.c:788
          frame #12: python`main(argc=2, argv=0x00007fff5fbff260) at python.c:65
          frame #13: 0x00007fffcb6dc235 libdyld.dylib`start + 1
      

        Attachments

        1. PYSIDE-585.patch
          0.7 kB
        2. pyside585.py
          0.3 kB

          Issue Links

          For Gerrit Dashboard: PYSIDE-585
          # Subject Branch Project Status CR V

            Activity

              People

              • Assignee:
                ctismer Christian Tismer
                Reporter:
                empyrical empyrical
              • Votes:
                4 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes