Skip to content

SG-38851: Fix random segfault in test tearDown with Qt event processing#1085

Draft
julien-lang wants to merge 3 commits intomasterfrom
ticket/SG-38851-try-fixup-seg-fault
Draft

SG-38851: Fix random segfault in test tearDown with Qt event processing#1085
julien-lang wants to merge 3 commits intomasterfrom
ticket/SG-38851-try-fixup-seg-fault

Conversation

@julien-lang
Copy link
Member

@julien-lang julien-lang commented Feb 9, 2026

Fixes random segmentation faults during test tearDown when Qt objects are destroyed.

Problem:
Tests randomly fail with segfault in tearDown across all platforms (Linux, Windows, macOS) and Python versions. The crash occurs after all Python code completes, during Qt object destruction at line 105 in tests/external_config/init.py.

Root Cause:
Qt's deleteLater() mechanism creates deferred deletions that aren't processed before tearDown completes, leaving dangling pointers that cause segfaults during C++ cleanup.

Solution:
Added cleanup_qtapp() method that calls QCoreApplication.processEvents() twice to allow Qt's event loop to process all deferred deletions before clearing global shotgun connections.

Testing:
Includes debug logging and 2-second sleep for verification. Will remove after CI confirms the fix works.

@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.64%. Comparing base (b8b3764) to head (f006847).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1085      +/-   ##
==========================================
- Coverage   79.65%   79.64%   -0.01%     
==========================================
  Files         198      198              
  Lines       20620    20620              
==========================================
- Hits        16424    16422       -2     
- Misses       4196     4198       +2     
Flag Coverage Δ
Linux 79.09% <ø> (ø)
Python-3.10 79.31% <ø> (-0.16%) ⬇️
Python-3.11 79.36% <ø> (ø)
Python-3.13 79.00% <ø> (-0.35%) ⬇️
Python-3.9 79.41% <ø> (ø)
Windows 79.13% <ø> (-0.01%) ⬇️
macOS 79.10% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

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.

1 participant

Comments