Skip to content

Python 3.13 Qt segfault after QWidget.screen() on the comments figure #1063

Backlog

Description

@neuromechanist

Summary

On Ubuntu with Python 3.13, the test suite crashed with a segmentation fault in Qt when a QDialog was built after the comments figure of pop_comments (#929) had been destroyed.
The crash needed the call dialog.screen() in build_comments_figure (src/eegprep/functions/guifunc/qt_comments.py).
PR #1062 replaces it with QApplication.primaryScreen(), which avoids the crash, but the root cause is not fixed.

Reproduction

  • Linux, Python 3.13.18, PySide6 6.11.0 (the locked packages), with dialog.screen() in build_comments_figure.
  • Command:
pytest tests/test_plugin_menu.py tests/test_pop_comments.py::test_comments_figure_resizes_like_matlab tests/test_pop_editeventfield_current.py

It does not occur with Python 3.12, on macOS or on Windows.

Qt stack

The crash is at the next QDialog() built after the comments figure was destroyed:

QScreen::virtualSiblings() const
QGuiApplication::screenAt(QPoint const&)
QWidget::screen() const
QWidget::metric(QPaintDevice::PaintDeviceMetric) const
QFont::QFont(QFont const&, QPaintDevice const*)
QWidgetPrivate::init(QWidget*, QFlags<Qt::WindowType>)
QDialog::QDialog(QWidget*, QFlags<Qt::WindowType>)

Cause

Not established.
A plausible cause is the ownership of the QScreen wrapper that dialog.screen() returns under Python 3.13.
Observations so far:
the same call on an ordinary dialog (qt.py, _apply_spec_size) does not crash,
a standalone script that repeats the test does not crash,
and defining the dialog class once instead of at every call did not help.

Remaining exposure

src/eegprep/functions/guifunc/qt.py:1371 (dialog.screen().availableGeometry() in _apply_spec_size, which sizes every dialog that build_dialog renders) still calls screen() on a dialog and is the remaining exposure.

Regression guard

The Python 3.13 Ubuntu CI job is the regression guard: it stopped at 63% with the segmentation fault before #1062.


Agentic AI tools were used. Workflows follow the Research Skills (doi:10.5281/zenodo.20696515). The author assumes full responsibility for this content and associated changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions