Repository navigation
Description
Before you start
- I searched the existing issues and did not find a duplicate.
- This is a bug report, not a usage question.
What happened?
The Qt-enabled Python CI job (test / Test (ubuntu-latest, Python 3.12), the only job that installs Qt WebEngine) segfaults with exit 139 in roughly 0.5–2% of runs; a rerun passes. The Python frame in the log moves around: Session() construction, a numpy import, _collections_abc. That frame is only where the main thread happened to be.
Core dumps show the fault is on a Qt WebEngine thread:
#3 getenv () from libc.so.6
#4 ?? () from libgallium-25.2.8-0ubuntu0.24.04.4.so
#5 driCreateNewScreen3 () from libgallium-25.2.8-0ubuntu0.24.04.4.so
#6-#9 ?? () from libEGL_mesa.so.0
#10 ?? () from libQt6WebEngineCore.so.6
WebEngine sets up EGL (Mesa) on its GPU thread, and Mesa reads the environment there. Meanwhile the main thread adds environment variables: monkeypatch.setenv("RUSTGIS_CONFIG_DIR", ...) in the saved-secrets tests, numpy's first import (OPENBLAS_MAIN_FREE), and pytest's PYTEST_CURRENT_TEST. glibc's setenv can move and free the environment array while getenv is reading it. Details and verification are in this comment. RustGIS itself is not involved; the crash affects the test suite.
Steps to reproduce
- Run the Python 3.12 job of
.github/workflows/test-python.yml(Qt system libraries,RUSTGIS_TEST_QT=1, extrastest,geopandas,qt,--features test-stores). python -m pytest -qinapps/rustgis-python; about 1 run in 50–200 crashes.
A faster repro is to add and remove environment variables in a loop while QWebEngineViews start under QT_QPA_PLATFORM=offscreen. That crashed in getenv in 17 of 30 cold runs on ubuntu-latest, and in 0 of 30 with --webEngineArgs --disable-gpu.
Expected behavior
The Python suite completes without a native crash.
How are you running RustGIS?
Python package built from source in GitHub Actions (none of the template's choices apply).
Version
0.4.0; first seen on main and PR merge commits around 2026-10-28.
Operating system, browser and graphics
Ubuntu 24.04 (ubuntu-latest), Python 3.12.15, PySide6 6.12.0 / Qt WebEngine 6.12.0.140, Mesa 25.2.8.
Sample data
None needed.
Screenshots or logs
Crashed CI runs: 40657663134, 40750952515, 40768155574, 40770996179. Core dumps and verification runs: 40778483078, 40783193853.
Activity
deniial00 commentedon Oct 28, 2026
Investigation found a definite Qt test-lifetime defect, but has not established the original native fault's exact cause.
test_qt.pyreturned widgets without native teardown and retainedQApplicationonly for that module. Widgets contain a bound-callback reference cycle, so Python reference-counting does not dispose of them when a test ends.MapWidget; the smoke failed there. This demonstrates uncontrolled cleanup timing independently of the original segfault.QApplicationfor the test session and routes every test-created widget through a yield fixture. Itsfinallycloses widgets, schedules native destruction, and explicitly deliversDeferredDeleteevents on the GUI thread. No session locking changes, skipped tests, dependency pins, or separate-process workaround.Qt requires the application to be the first-created and last-destroyed QObject: https://doc.qt.io/qt-6/threads-qobject.html.
[INFERENCE]Uncontrolled Qt cleanup caused the original laterSession()crash. The lifetime bug and its correction are demonstrated; the original exit 139 has not been reproduced locally, so this issue should not yet be treated as a conclusively diagnosed native crash.Additional verification: cross-built current-source bindings run on Linux x86_64/Python 3.12 under Docker emulation. The GC-disabled Qt lifetime smoke plus saved-secrets tests passes (8 tests); the complete suite passes with 41 tests and one optional GeoPandas skip. The original fixture version also passes that x86 full-suite run, further limiting the causal claim. These local Linux runs are Debian-based, not the original Ubuntu runner image.
Ownership follow-up: a stronger GC-disabled smoke deliberately retained the widget, bridge, view, and page wrappers while ending the fixture, and checked native
destroyedsignals. It exposed one additional gap: the unparented bridge survived widget deletion. Fixture teardown now explicitly schedules the bridge for deletion too. The smoke now observes destruction of all four native objects and no survivors; bridge message delivery was exercised before teardown. The complete macOS Python 3.12 suite passes again (42 tests). The Linux results above precede this final bridge-cleanup addition. The original SIGSEGV remains unconfirmed.deniial00 commentedon Oct 28, 2026
CI history for the Python workflow (last 200 runs, 2026-10-27 21:45Z to 2026-10-28): four first attempts segfaulted. All passed on rerun, and all failures were in
Test (ubuntu-latest, Python 3.12), the only job that installs Qt WebEngine and setsRUSTGIS_TEST_QT=1.test_session.py::test_geopandas_round_trip<frozen _collections_abc>__new__(pure Python), after 7 testsSession(use_saved_secrets=True),test_saved_secrets.py:53Session(),test_saved_secrets.py:54Session()itself.[INFERENCE]Next: get a baseline failure rate by running the original suite repeatedly on Ubuntu 24.04 x86_64. Then run the same loop with the fixture change. Keep core dumps or a gdb backtrace so the native frame is captured.
ci: cold stress runs, env fix variant, setenv race repro (opengeos#1113…
ci: verify the WebEngine GPU-off fix for opengeos#1113 (temporary)
deniial00 commentedon Oct 28, 2026
Root cause found and fix verified. This supersedes my two earlier comments: the Qt widget-lifetime issue was real, but it was not the cause, and
Session()was never the crashing code.Cause. The segfault happens on a Qt WebEngine thread, not the Python main thread. Two core dumps from stress runs on
ubuntu-latest(Python 3.12, this job's exact build) show the same faulting stack:WebEngine sets up EGL (Mesa) on its GPU thread, and Mesa reads the environment there. When the main thread adds an environment variable, glibc's
setenvcanreallocthe environment array and free the old one while thatgetenvis still walking it. The suite has several such writers after the Qt tests start:monkeypatch.setenv("RUSTGIS_CONFIG_DIR", ...)in the saved-secrets tests, numpy's first import (os.putenv("OPENBLAS_MAIN_FREE", ...); the 08:33Z crash was in that import), and pytest's ownPYTEST_CURRENT_TEST. The Python frame in each CI log is just where the main thread happened to be, which is why the crash site kept moving. It is also why the crash is rare (about 0.5–2% of runs) and only in the Python 3.12 job, the only one that installs Qt WebEngine.Fix. Run the Qt tests with WebEngine's GPU off: the test
QApplicationgets--webEngineArgs --disable-gpu. The tests never draw the page, so nothing else changes.Verification (fork run,
ubuntu-latest, Python 3.12, release wheel withtest-stores, extrastest,geopandas,qt):driCreateNewScreen3during the full suitegetenv(15 under Mesa EGL setup, one with the exact CI stack)The core dumps came from an earlier stress run (400 suite runs, 2 crashes). Residual risk: two of the 17 repro crashes were in other
getenvcallers (glibc's resolver and WebEngine itself). The GPU-off arm had none of either in 30 runs, but setting environment variables while WebEngine threads run is not safe in general.The fix also keeps a smaller change that is unrelated to the crash: the Qt test fixtures now destroy each widget and its unparented message bridge at teardown, instead of leaving them to Python's cyclic garbage collector.
[-][Bug]: Python Qt-enabled test suite segfaults while constructing a Session[/-][+][Bug]: Qt-enabled Python tests segfault in getenv on Qt WebEngine's GPU thread[/+]fix(python): run the Qt tests without WebEngine's GPU (#1113) (#1117)