Details
Description
In sbkmodule.cpp, line 472, the original _import_ function is fetched from the builtins dict without incrementing the reference count.
If later the _import_ function in the builtins is replaced then the one held here will be destroyed leaving an invalid function object, which will cause a crash on the next import.
A Py_INCREF should follow PyDict_GetItemString, since that returns a borrowed reference:
static PyObject *origImportFunc{}; .. static PyObject *lazy_import() ... origImportFunc = PyDict_GetItemString(builtins, "__import__"); Py_INCREF(origImportFunc) // This is missing around line 473
It looks like this bug was introduced in commit 7accf7c3042e3f0680fa0615a0f13b54d28a0efd "LazyInit: Implement Lazy Initialization by Delayed Module Entries" https://codereview.qt-project.org/c/pyside/pyside-setup/+/539467
Attachments
Issue Links
- relates to
-
PYSIDE-2404 Create an On-Demand Initializer for PySide
- Open