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

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 6.3.0
    • Fix Version/s: None
    • Component/s: PySide
    • Labels:
      None
    • Environment:
      Python 3.10
    • Platform/s:
      All
    • Commits:
      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

              Assignee:
              kleint Friedemann Kleint
              Reporter:
              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