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

Crash on "deallocating None" triggered via Shiboken

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.5.6, 6.8.0, 6.7.1
    • 6.6.0, 6.5.3, 6.6.1, 6.6.2, 6.6.3
    • PySide, Shiboken
    • None
    • Python 3.11, amd64
    • Linux/X11, Windows
    • f89113e21 (dev), 8b302d296 (6.7), b0be45b23 (6.6), 195ad4311 (tqtc/lts-6.5)

    Description

      My program makes many calls to Python standard library function inspect.getdoc(). After approximately 10000 of these calls, the Python interpreter reports a fatal error "deallocating None". This happens only if the module PySide6 has been imported.

      It is very easy to reproduce this issue. My testcase is listed below and also attached to this issue.

      This issue occurs with PySide6 versions 6.6.3, 6.6.2, 6.6.1, 6.6.0 and 6.5.3, but I was not able to reproduce it with version 6.5.2. (Packages as published on PyPI.)

      This issue occurs with Python 3.11.6 for Windows as well as Python 3.11.2 for Linux.
      The issue does not occcur with Python 3.12.2, probably because reference counting of None has been removed from Python 3.12.

      It seems to me that there is a bug involving reference counting somewhere in the code of shibokensupport.signature. I would much appreciate it if someone with more understanding of this code can confirm the bug and suggest a fix.

      This Python program reproduces the issue:

      import inspect
      import PySide6
      
      # The crash usually occurs after ~ 10000 iterations of this loop.
      for i in range(1000000):
          inspect.getdoc(int.bit_count)
          print(i)
      

      The Python interpreter prints the following error message (PySide 6.6.3):

      Fatal Python error: none_dealloc: deallocating None: bug likely caused by a refcount error in a C extension
      Python runtime state: initialized
      
      Current thread 0x00007fd89e042040 (most recent call first):
        File "shibokensupport/signature/loader.py", line 43 in make_helptext
        File "/usr/lib/python3.11/inspect.py", line 855 in getdoc
        File "/home/qslab/joris/test_crash.py", line 7 in <module>
      
      Extension modules: xxsubtype, shiboken6.Shiboken (total: 2)
      Aborted
      

      Attachments

        1. pyside_issue2660_fix.patch
          0.7 kB
        2. pyside2660_stack.txt
          6 kB
        3. pyside2660.py
          0.4 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ctismer Christian Tismer
            jorisvr Joris van Rantwijk
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes