Possible reload-related PyQt6 crash in dynamic metaobject construction

Phil Thompson phil at riverbankcomputing.com
Sat Sep 19 09:06:37 BST 2026


My comments still stand. SIP's ABIs v12 (PyQt5) and v13 (PyQt6) were 
never designed to support module reloading (and never will). The 
solution will be ABI v14 which is currently experimental and requires 
Python v3.15. I'm currently in the process of adding support for v14 to 
PyQt5.

Phil

On 19/09/2026 01:35, Matthias Schabel wrote:
> Hi,
> 
>   I’m seeing a segmentation fault while activating a window in a
> long-running Spyder session using a napari-based application. The
> native stack
>   reaches PyQt’s dynamic metaobject builder:
> 
>   QEventLoop::exec
>     → QGuiApplicationPrivate::processFocusWindowEvent
>     → QApplicationPrivate::setActiveWindow
>     → QWidget::isActiveWindow
>     → QMetaObject::cast
>     → qpycore_get_qmetaobject
>     → qpycore_get_dynamic_metaobject
>     → trawl_hierarchy
>     → PyObject_GetAttr
>     → PyObject_GenericGetAttr
> 
>   The fault is EXC_BAD_ACCESS at 0x10, on the main thread during
> normal window activation.
> 
>   This may relate to the August 2024 discussion about a crash after
> module reload and __class__ replacement
> 
> (https://www.riverbankcomputing.com/pipermail/pyqt/2024-August/045990.html),
> where SIP’s reload handling was acknowledged as a bug.
> 
>   A synthetic subprocess probe produces these results:
> 
>   - Construct a Python QObject subclass and invoke its native
> metaObject() without the GIL: survives.
>   - First apply IPython’s update_class(old, new), which replaces the
> live instance’s __class__: segfaults.
>   - After that replacement, call obj.metaObject() from Python before
> the native call: survives.
> 
>   The hypothesis is that class replacement bypasses initialization of
> the replacement type’s Qt metadata, allowing a later native call to
> enter the
>   Python-dependent builder without the GIL.
> 
>   The probe uses ctypes to invoke the native virtual. I don’t yet have
> a minimal reproducer using ordinary Qt event dispatch, and haven’t
> established
>   that autoreload caused the original crash. Spyder’s configuration
> enables both IPython autoreload and its separate UMR feature.
> 
>   The probe reproduces with Python 3.12.12, PyQt6 6.11.0, Qt 6.11.2,
> and IPython 9.16.1 and 9.17.1 on macOS 26.5.1, Apple Silicon.
> 
>   Thanks,
>   Matthias


More information about the PyQt mailing list