Skip to content

Tests: close leftover top-level widgets at session end (PySide6 6.12 exit crash) — v0.10.7 - #177

Merged
jamesabel merged 1 commit into
masterfrom
fix/close-leftover-widgets-pyside-6-12
Oct 20, 2026
Merged

jamesabel merged 1 commit into
masterfrom
fix/close-leftover-widgets-pyside-6-12

Conversation

@jamesabel

Copy link
Copy Markdown
Owner

What was broken

CI has failed on every run since PySide6 6.12.0 was published (2026-10-08), including a plain re-run of the last green master commit: all tests pass, then the pytest process dies at interpreter exit.

================== 519 passed, 4 skipped in 139.38s (0:02:19) ==================
QObject: shared QObject was deleted directly. The program is malformed and may crash.
Segmentation fault      (core dumped) coverage run --source=src -m pytest tests
##[error]Process completed with exit code 139.
Run PySide6 Outcome
master, 2026-09-29 (original run) 6.11.2 green
master, re-run 2026-10-19 6.12.0 segfault at exit
PR #176, two runs 6.12.0 segfault at exit

Root cause

The suite leaves about 100 top-level widgets alive at session end: Configuration tabs (tests/test_configuration.py, tests/test_gui_display.py), FlyAppMainWindows (tests/test_gui_widgets.py), an OrderingAspectsWidget, combo-box popup frames and a tooltip. Up to PySide6 6.11 these were destroyed silently during interpreter shutdown. From 6.12.0, PySide::destroyQCoreApplication destroys them after the application teardown has begun, Qt reports "shared QObject was deleted directly" and the process aborts (exit 139 on Linux, 0xC0000409 on Windows). Other projects report the identical failure and fix.

The change

  • tests/conftest.py — a new autouse session fixture closes and deletes every remaining top-level widget while the QApplication still exists, then delivers the deferred deletes. Widgets first, application last, which is the order Qt expects. Existing tests are untouched.
  • .github/workflows/main.yml, tox.ini — PySide6 6.12.0 declares requires-python <3.16, so the 3.15 job's --ignore-requires-python override is dropped, as the note next to it said to do once a release declared 3.15 support.
  • pyproject.toml — 0.10.7.

Verification

Full suite, Python 3.14, QT_QPA_PLATFORM=offscreen, exact process exit code captured:

PySide6 Before After
6.12.0 525 passed, exit 0xC0000409 525 passed, exit 0
6.11.1 525 passed, exit 0 525 passed, exit 0

ruff check and ruff format --check are clean.

Unblocks #176.

🤖 Generated with Claude Code

…exit crash) — v0.10.7

PySide6 6.12.0 (released 2026-10-08) aborts the interpreter at shutdown when
top-level widgets are still alive: PySide::destroyQCoreApplication destroys
them after the suite has finished and Qt reports "QObject: shared QObject was
deleted directly" followed by a segfault (exit 139 on Linux, 0xC0000409 on
Windows). CI picked the new wheel up on the first run after its release, so
every job now fails with all tests green — on master as much as on any PR.

The suite leaves ~100 top-level widgets behind (Configuration tabs,
FlyAppMainWindows, the ordering widget, combo-box popup frames, a tooltip).
A new autouse session fixture closes and deletes them while the QApplication
still exists and the event loop can deliver the deferred deletes, which is
the order Qt expects: widgets first, application last. Verified on Python
3.14 with PySide6 6.12.0 (525 passed, exit 0; previously exit 0xC0000409)
and with PySide6 6.11.1.

PySide6 6.12.0 also declares requires-python <3.16, so the 3.15 job's
--ignore-requires-python override and its note are dropped from the CI
workflow and tox.ini, as that note said to do once a release declared
3.15 support.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.70%. Comparing base (bfa652b) to head (172e262).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #177      +/-   ##
==========================================
+ Coverage   85.67%   85.70%   +0.03%     
==========================================
  Files          74       74              
  Lines        6450     6450              
==========================================
+ Hits         5526     5528       +2     
+ Misses        924      922       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jamesabel
jamesabel merged commit 08f9dac into master Oct 20, 2026
3 checks passed
@jamesabel
jamesabel deleted the fix/close-leftover-widgets-pyside-6-12 branch October 20, 2026 02:40
jamesabel added a commit to JingHao-Leon/pytest-fly that referenced this pull request Oct 20, 2026
…mesabel#177)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
jamesabel added a commit that referenced this pull request Oct 20, 2026
* test: reproduce live-output cache ignoring max_bytes

The decoded live-output cache is keyed by the file's (size, mtime_ns) only, but
the text it holds is the *tail* of the file and therefore depends on max_bytes.
A read with one byte limit can be served the tail computed for a different one.

Adds two regression tests that fail on the current implementation:
  - a large-limit read after a small-limit read must not reuse the small tail
  - a small-limit read after a large-limit read must not return more than the limit

* fix: key the live-output cache by the requested byte limit

The decoded live-output cache was keyed by the log file's path alone, but the
text it stores is the *tail* of that file, so the cached value also depends on
the max_bytes limit the read was made with. The first call for a given file
therefore fixed the length of the text every later call received.

This is reachable in the app: the Table tab and the Live Output pane read the
same log file with the 65536-byte default, while resolve_test_output() asks
for 10,000,000 bytes. Whichever ran first decided how much output the others
saw -- a read could return far fewer bytes than requested (with a spurious
"...[truncated]..." marker) or far more than requested.

Key the cache by (path, max_bytes) so each limit gets its own cached tail.

Also bumps the version to 0.10.7.

* Bump to 0.10.8: 0.10.7 was taken by the PySide6 6.12 teardown fix (#177)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: JamesAbel <j@abel.co>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants