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

Segfault when garbage collector grabs object with connected signal

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 6.3.0
    • PySide
    • None
    • Python 3.10
    • All
    • 5b8ca1b92d (pyside/pyside-setup/dev) 6a6238d525 (pyside/pyside-setup/6.3) 6a6238d525 (pyside/pyside-setup/wip/6.3_pypy) 6a6238d525 (pyside/tqtc-pyside-setup/6.3) 5b8ca1b92d (pyside/tqtc-pyside-setup/dev)

    Description

      Hi PySide dev team,

       
      PyQtGraph dev here, we noticed a segfault on PySide6 6.3.0 and python 3.10 (this segfault does not occur on python 3.9 or python 3.8).  When the garbage collector cleans up an object that has a connected signal, this triggers a segfault.  Here is a minimum reproducible example, along with a commented-out fix.

      import gc
      from PySide6 import QtCore
      
      class X(QtCore.QObject):
          signal = QtCore.Signal()
      
          def callback(self):
              pass
      
      child, parent = X(), X()
      
      parent._child = child
      child._parent = parent
      meta = child.signal.connect(parent.callback)
      print('before gc')
      del child, parent
      # uncomment to fix segfault
      # QtCore.QObject.disconnect(meta)
      gc.collect()
      

      EDIT: messed up on a spacing issue in the code snippet, fixed now.

      Attachments

        1. pyside1919_log.txt
          2 kB
        2. pyside1919_trace.txt
          25 kB
        3. pyside1919.py
          0.7 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kleint Friedemann Kleint
              j9ac9k Ognyan Moore
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes