Repository navigation
apk: the phone's Python is the runtime's (3.14.8), not p4a's 3.14.2 with its incremental GC - #2122
Merged
Merged
Conversation
…ith its incremental GC The phone's SIGSEGV at 03:48, symbolized with the NDK's llvm-addr2line against the build's own libpython3.14.so: _PyObject_IS_GC <- mark_stacks <- gc_collect_increment <- _PyGC_Collect <- _Py_HandlePending, in qasync's _QThreadWorker while it built a tuple from a generator. That's CPython 3.14.2's incremental GC reading a NULL type (fault addr 0xa8, tp_flags) off a thread's stack. CPython reverted the incremental GC in 3.14.5. p4a 58d21141 pins 3.14.2; the desktop runtime that compiles the APK's bytecode and runs every bundle check is 3.14.8. tools/android/recipes/python3 and hostpython3 are p4a's recipes at TOAD_ANDROID_PYTHON, which build.sh reads from the runtime, so the runtime owns which Python ships. p4a's patches are applied from p4a's own folder. After packaging, tools/android/apk_python.py reads PY_VERSION from the APK's libpython and fails the build unless it is the runtime's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
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.
The phone crashed at 03:48 with
SIGSEGV(SEGV_MAPERR, fault addr 0xa8) in qasync's_QThreadWorker. I symbolized its backtrace with the NDK'sllvm-addr2lineagainst the build's ownlibpython3.14.so, which is byte-identical to the one in the dist:That's CPython 3.14.2's incremental GC, triggered in a worker thread while it built a tuple from a generator.
mark_stackswalks every thread's frame stack, and it read a stack slot whose type pointer is NULL (0xa8 isPyTypeObject.tp_flags). The crash is in CPython's own collector, not in a C extension, PySide or our render work. CPython reverted the incremental GC in 3.14.5 after mark_stacks bugs, among them gh-148144, an uninitializedframe->visitedon copied generator frames (Python 3.14.5 rolls back the incremental garbage collector; discussion). p4a 58d21141 pins 3.14.2, while the desktop runtime, which compiles the APK's bytecode and runs every bundle check, is 3.14.8.What changed
tools/android/recipes/python3andhostpython3(new): p4a's recipes atTOAD_ANDROID_PYTHON. p4a's own patches are applied from p4a's folder, not copied. The two patches p4a wrote against 3.14.2 whose change CPython has since made itself (3.14_armv7l_fix.patch,3.14_fix_remote_debug.patch) are declared with the source line that carries each change. Each is skipped only where that line is present; otherwise the build fails. Their forward application fails against 3.14.8, and the other four p4a patches apply in sequence with no rejects.tools/android/build.shreads the runtime's version intoTOAD_ANDROID_PYTHON, so the runtime owns which Python ships. After packaging it runs:tools/android/apk_python.py(new), which readsPY_VERSIONfrom the APK's own libpython and fails the build unless it is the runtime's. Run on the current main APK it reports3.14.2and fails, as it should.Evidence
I built in a scratch APP folder seeded from the shared build cache, with python3 and hostpython3's build state removed.
PY_VERSIONPython/gc.cmark_stacks+gc_collect_increment_PyGC_Collect→gc_collect_main(generational); nomark_stacksin gc.cmark_stackssymbol left in the new libpython isObjects/frameobject.c's, a bytecode stack-depth analysis forf_lineno, not the GC's.build.sh(which runscheck.shfirst) exited 0. It printed "shipped app ran every view kind and bound key on a scratch bus", then "the APK's interpreter is Python 3.14.8".check.shandshipped_runrun the shipped bundle on the desktop runtime's 3.14.8 interpreter, not the arm64 one. The phone is the only place the new interpreter itself runs. qt start: a native crash leaves every thread's Python stack in the errors folder #2116's fault trace will capture every thread's stack if anything native still faults there.🤖 Generated with Claude Code
https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3