Skip to content

fix(tests): stop the game detection popup tests segfaulting Ubuntu CI - #85

Open
kalopsia-space wants to merge 1 commit into
linux-2.0from
fix/linux-2.0-test-segfaults
Open

kalopsia-space wants to merge 1 commit into
linux-2.0from
fix/linux-2.0-test-segfaults

Conversation

@kalopsia-space

Copy link
Copy Markdown
Collaborator

Problem

On linux-2.0 the Ubuntu Python 3.12 and 3.14 Tests steps segfault in tests/test_game_detection_popup.py (run 39039653469). The crash kills the single-process pytest run at about 41%, so no Linux test after that point reports anything.

Root cause

  1. GameDetectionPopup._build_ui queues _refresh_running_windows with QTimer.singleShot(0).
  2. test_removing_rules_clears_nested_row_widgets patches sys.platform to 'win32', then calls popup.show() and qapp.processEvents().
  3. During processEvents() the queued slot runs _enumerate_capturable_windows(). That takes the Win32 branch, and ctypes.windll raises AttributeError on Linux.
  4. PySide6 6.11.1 keeps that slot error pending for the rest of a Python-driven processEvents(). The next Python virtual dispatched in the same pass is the paintEvent override of IconButton or _ToggleSwitch. It crashes inside Shiboken's override lookup.

Native stack (faulthandler, which the app's crash logging redirects to $HOME/.fthr/logs/fthr-crash.log; gdb gives the same frames):

Fatal Python error: Segmentation fault
  File "tests/test_game_detection_popup.py", line 60 in test_removing_rules_clears_nested_row_widgets   # qapp.processEvents()
libpython3.14  _Py_Dealloc
libpython3.14  _Py_Dealloc
libshiboken6   Shiboken::BindingManager::getOverride(SbkObject*, _object*)
libshiboken6   Sbk_GetPyOverride(...)
QtWidgets.abi3 <wrapper paintEvent>
libQt6Widgets  QWidget::event
libQt6Widgets  QWidgetPrivate::sendPaintEvent / drawWidget / paintSiblingsRecursive x8
libQt6Widgets  QWidgetRepaintManager::paintAndFlush / sync
libQt6Gui      QGuiApplicationPrivate::processExposeEvent
libQt6Core     QEventDispatcherGlib::processEvents

Bisection (stand-alone script, offscreen):

  • The crash happens only when sys.platform == 'win32' at paint time. Setting it only during construction is fine.
  • A minimal PySide-only repro crashes: a slot that raises, QTimer.singleShot(0, slot), a QPushButton subclass with a Python paintEvent, then app.processEvents().
  • With a plain QPushButton there is no crash; processEvents() re-raises the AttributeError instead.
  • A slot that does not raise does not crash.
  • Under app.exec() the error is printed and the loop continues. The shipped app is not affected; only tests that pump processEvents() from Python can hit it.

Fix

An autouse fixture in tests/test_game_detection_popup.py stubs capture_settings_widget._enumerate_capturable_windows to []. The deferred refresh then neither raises nor shells out to hyprctl/xdotool from a test. test_windows_running_window_can_be_added_and_blocked still installs its own stub on top. No product code changes and no Windows behaviour change.

Local verification (Arch, Python 3.14.8, PySide6 6.11.1, offscreen, isolated HOME, CI command and ignore list)

35 failed, 1702 passed, 27 skipped in 81.7s. The run finishes, and test_editor_sessions.py also passes in-process. The remaining failures are real test failures, not crashes, and are out of scope here:

  • camera provider / Linux camera refresh (17)
  • capture settings popup monitor recovery (3)
  • game detector polling and missing Linux tools, foreground Java rule (3)
  • screenshot portal / grim fallback and screenshot save (3)
  • test_game_detection_popup::test_browse_executable_adds_and_persists_game: _validate_game_selection still requires .exe on Linux. This is a real 2.0 UI bug that the segfault was hiding.
  • single tests: alpha stability probe, alpha UI truth crop, clip viewer P1, design overhaul sliders, encoder settings, settings defaults, Windows troubleshooting docs
  • test_capture_backend_detection::test_binary_exists: local only, because the engine is not built locally

ruff check . is clean and tools/verify_exception_handling.py passes.

GameDetectionPopup queues _refresh_running_windows with
QTimer.singleShot(0). In the tests that patch sys.platform to 'win32'
on Linux, that slot reaches ctypes.windll and raises AttributeError.
PySide6 6.11 keeps a slot error raised inside a Python-driven
QApplication.processEvents() pending; the next Python virtual it
dispatches in the same pass (IconButton/_ToggleSwitch paintEvent) then
segfaults in Shiboken::BindingManager::getOverride, killing the whole
single-process pytest run on Ubuntu.

Stub _enumerate_capturable_windows for the module so the deferred
refresh neither raises nor shells out to hyprctl/xdotool.
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