Skip to content

fix(viewer): destroy the Qt objects before interpreter exit - #59

Merged
Everlite merged 2 commits into
Everlite:devfrom
Scyllinice:fix/viewer-exit-crash
Nov 10, 2026
Merged

Everlite merged 2 commits into
Everlite:devfrom
Scyllinice:fix/viewer-exit-crash

Conversation

@Scyllinice

Copy link
Copy Markdown
Contributor

Fix Console Hub crash on exit

Problem

Every quit of the Console Hub ended in a segfault, or a corrupted double-linked list abort, and left a ~13 MB core dump. Capture had already shut down cleanly by then, so nothing was lost apart from the core dump.

#0 QObject::~QObject()                      (libQt6Core)
#3 Shiboken::BindingManager::visitAllPyObjects
#4 PySide::destroyQCoreApplication()
#5 PySide::runCleanupFunctions()

PySide's interpreter-exit cleanup destroys a QObject that has already been destroyed.

Fix

Once app.exec() returns, main() calls a new _destroy_qt_objects(). It hides the tray icon and window, deletes the window through the event loop and flushes the deferred deletes while Python still owns the objects. Then it exits with the same code as before.

Testing

  • Reproduced with QT_QPA_PLATFORM=offscreen, running the real viewer and quitting through the tray Quit path (_force_quit) after 4 s: 3/3 crashes before, 5/5 clean exits after, plus 2/2 clean exits when started with --tray.
  • On the desktop (Arch, Python 3.14, PySide6 6.12, Wayland): no core dumps on quit after the fix. Before, every quit left one.

Scyllinice and others added 2 commits November 9, 2026 22:45
Every quit of the Console Hub ended in a segfault or a 'corrupted
double-linked list' abort.  PySide's interpreter-exit cleanup
(PySide::destroyQCoreApplication -> visitAllPyObjects) destroys a
QObject that was already gone, leaving a ~13 MB core dump each time.
Capture has already shut down cleanly by then, so nothing is lost
apart from the core dump.

After app.exec() returns, hide the tray icon and window, delete the
window through the event loop, and flush the deferred deletes while
Python still owns the objects.  Then exit.

Reproduced off-screen (QT_QPA_PLATFORM=offscreen, quitting through the
tray Quit path after 4 s): 3/3 crashes before, 5/5 clean exits after,
plus 2/2 clean exits when started with --tray.
@Everlite
Everlite merged commit 951f3cd into Everlite:dev Nov 10, 2026
@Everlite

Copy link
Copy Markdown
Owner

Thank you for tracking down this shutdown crash!

We tested this locally with the viewer: exiting via both the window close button and the system tray now terminates the application cleanly without leaving any double-linked list aborts or core dumps behind.

Merged into dev. Really appreciate your help with keeping the desktop app stable and polished!

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