Skip to content

qt start: a native crash leaves every thread's Python stack in the errors folder - #2116

Merged
trissim merged 2 commits into
mainfrom
fork-android-worker-segv
Nov 18, 2026
Merged

trissim merged 2 commits into
mainfrom
fork-android-worker-segv

Conversation

@trissim

@trissim trissim commented Nov 18, 2026 •

Copy link
Copy Markdown

The phone crashed at 03:48 with SIGSEGV in qasync's _QThreadWorker (a null pointer read inside libpython) and left nothing Python could read: a fault in C kills the process before any handler runs, so paths.save_error never sees it.

What changed

  • toad.fatal_trace.FatalTrace (new, shared): opens this run's fatal_<time>.txt under the errors folder, routes faulthandler (all threads) into it and keeps it open for the life of the process. At a clean exit it disables tracing and removes the file when nothing was written, so a fatal_* file exists only for a run that crashed.
  • Both Qt entries (toad.qt.android.main, toad.qt.main.main) call FatalTrace.enabled() first, before Qt starts.
  • tools/android/shipped_run.py checks, on the shipped interpreter and bundle:
    • that both entries' main open the trace;
    • that a clean run leaves no fatal_* file;
    • that a run which faults (faulthandler._sigsegv()) exits with -11 and leaves a trace holding "Segmentation fault" and "Current thread".

Also: an observation outage says how long the UI had gone without a result

The phone's ConnectorObserverClosed at 03:46 ("the local side stopped reading (BlockingIOError)") is the relay's SO_SNDTIMEO, which resets on every accepted byte. So the UI's reader took nothing for 30 s, while the frame probe shows the UI loop never stalled past 311 ms. I measured qasync's executor at phone throttle over a history drive with the in-thread renderer: at most 3 of its 10 workers were busy, never all 10, and the worst queue wait was 291 ms. So executor starvation doesn't reproduce and I'm not claiming it. ObservationRetry now owns when the last result reached the UI (arrived). The outage the reader is told about carries that age as a note in its saved traceback, so the next one says whether the reader went quiet for the whole deadline. The bus switch keeps recovered(), which isn't an arrival.

Evidence

What it found already

I symbolized the 03:48 crash with the NDK's llvm-addr2line against the build's own libpython3.14.so. The chain is _PyObject_IS_GC ← mark_stacks ← gc_collect_increment ← _Py_HandlePending: CPython 3.14.2's incremental GC, in a worker thread that was building a tuple from a generator. The fix (Android's Python at the runtime's 3.14.8, where 3.14.5 reverted the incremental GC) is a separate PR; this one only makes the next native crash readable.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3

trissim and others added 2 commits November 18, 2026 04:30
…rors folder

The phone's SIGSEGV at 03:48 (_QThreadWorker, a null pointer read inside libpython) left nothing Python could read: a fault in C kills the process before any handler. toad.fatal_trace.FatalTrace opens this run's fatal_<time>.txt under the errors folder first thing in both Qt entries, routes faulthandler (all threads) into it, and removes it at a clean exit when nothing was written. shipped_run checks, on the shipped interpreter, that both entries open it, that a clean run leaves no file, and that a faulted run writes every thread's stack there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…thout a result

The phone's ConnectorObserverClosed at 03:46 ('the local side stopped reading (BlockingIOError)') means the relay's local write accepted no byte for its 30 s SO_SNDTIMEO: the UI's reader took nothing for 30 s, while the frame probe shows the UI loop never stalled past 311 ms. Starvation of qasync's executor doesn't reproduce on the desktop at phone throttle (peak 3 of 10 workers busy over a history drive), so the cause is not settled. ObservationRetry now owns when the last result reached the UI (arrived), and the outage the reader is told about carries that age as a note in its saved traceback, so the next one says whether the reader went quiet for the whole deadline. The bus switch keeps recovered(), which isn't an arrival.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
@trissim
trissim force-pushed the fork-android-worker-segv branch from 5aa1735 to b0d4ba9 Compare November 18, 2026 09:46
@trissim
trissim merged commit c316563 into main Nov 18, 2026
1 of 2 checks passed
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