Details
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