CHORE: Flaky Tests - skip subprocess shutdown/teardown tests under QEMU and fix detection - #673
Merged
Gaurav Sharma (bewithgaurav) merged 3 commits intoAug 13, 2026
Conversation
…ection the subprocess shutdown/teardown tests in test_013 and test_024 intermittently segfault on the qemu-emulated linux arm64 CI legs and force reruns. the crash is a latent use-after-free in odbc handle-teardown ordering (an unclosed DBC handle finalized by gc at interpreter shutdown after the process-lifetime ENV handle is gone, so SQLFreeHandle touches freed ENV memory). it is benign on native hardware and only turns fatal under qemu's page reuse plus altered gc timing, so it is a flaky heisenbug. is_qemu_emulated() was effectively dead: it only matched 'CPU implementer 0x51', which never appears under multiarch/qemu-user-static because the emulated aarch64 process sees the x86_64 host's /proc/cpuinfo. fix it to flag an aarch64 process when cpuinfo advertises implementer 0x51 (qemu-system) or lacks the arm-only 'CPU implementer' field entirely (qemu-user host passthrough). native arm64 and x86 stay unflagged. extend the existing skip to test_024's TestContextManagerCommit (all 24 cases run the subprocess-teardown path); test_013 already had the marker, and the detection fix makes it take effect. the underlying teardown-order uaf is tracked separately. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changesNo lines with coverage information in this diff. 📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.pybind.ddbc_bindings.h: 59.9%
mssql_python.pybind.logger_bridge.hpp: 70.8%
mssql_python.pybind.ddbc_bindings.cpp: 76.6%
mssql_python.__init__.py: 77.6%
mssql_python.row.py: 77.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection_pool.cpp: 81.4%
mssql_python.pybind.connection.connection.cpp: 84.3%
mssql_python.logging.py: 85.5%🔗 Quick Links
|
Gaurav Sharma (bewithgaurav)
marked this pull request as ready for review
August 12, 2026 13:53
Copilot started reviewing on behalf of
Gaurav Sharma (bewithgaurav)
August 12, 2026 13:54
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Python test suite to avoid flaky subprocess shutdown/teardown crashes on QEMU-emulated Linux ARM64 CI, while keeping the same tests running on native hardware.
Changes:
- Fixes QEMU user-mode emulation detection in
tests/conftest.pyso existing QEMU-only skips actually trigger on the affected CI legs. - Skips the entire subprocess-based context-manager transaction test class under QEMU to prevent intermittent SIGSEGVs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
tests/test_024_context_manager_transaction.py |
Adds a class-level skipif(QEMU) to avoid flaky subprocess teardown crashes under QEMU emulation. |
tests/conftest.py |
Updates is_qemu_emulated() logic to detect QEMU user-mode ARM64-on-x86_64 more reliably and documents the known-failure case. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
gargsaumya
approved these changes
Aug 13, 2026
Jahnvi Thakkar (jahnvi480)
approved these changes
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
the subprocess shutdown/teardown tests in
test_013_SqlHandle_free_shutdownandtest_024_context_manager_transactionintermittently segfault on the qemu-emulated linux arm64 CI legs and force reruns. the crash is a latent use-after-free in odbc handle-teardown ordering (an unclosed DBC handle finalized by gc at interpreter shutdown after the process-lifetime ENV handle is gone, soSQLFreeHandletouches freed ENV memory); it is benign on native hardware and only turns fatal under qemu's page reuse plus altered gc timing, which is why it is flaky and clears on rerun.test-only, two changes:
is_qemu_emulated()inconftest.py. the old check only matchedCPU implementer 0x51, which never appears undermultiarch/qemu-user-static(the emulated aarch64 process sees the x86_64 host's/proc/cpuinfo, which has no arm implementer field). it now flags an aarch64 process when cpuinfo advertises implementer0x51(qemu-system) or lacks the arm-onlyCPU implementerfield entirely (qemu-user host passthrough); native arm64 and x86 stay unflagged. the existingtest_013skip was dead because of this and now takes effect.skipif(QEMU)totest_024'sTestContextManagerCommit(all 24 cases run the subprocess-teardown path).the conftest docstring documents the underlying teardown-order uaf as the known-failure case. that root-cause bug is tracked separately and is unaffected by this skip; native legs still run these tests, so a regression there is not masked.