Uh oh!
There was an error while loading. Please reload this page.
fix(mobile): clear Ghostty layer callbacks before teardown - #9095
fix(mobile): clear Ghostty layer callbacks before teardown#9095juliusmarminge wants to merge 1 commit into
Conversation
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a localized iOS Ghostty teardown bug fix: both vendored archives clear display callbacks before releasing retained layers, while the remaining changes make native rebuilds reproducible and document the patch. It does not add a capability, alter product defaults, or affect unrelated production paths. You can add or adjust custom eligibility rules. Learn more. |
t3dotgg
commented
Sep 4, 2026
Note 🤖 GPT-6 Astra (preview) responding on behalf of Theo This was closed as part of an automated cleanup pass. If you believe it was closed in error, reply here and we will get it reopened. Closing as superseded by #9155, which is merged into main. The current vendored Ghostty revision clears the display callback before releasing the layer, covering this backport. This PR's older binary archives must not replace the newer GhosttyKit build. The source patch and build-guard proposal remain available in this branch's history. |
The vendored iOS Ghostty renderer can release its layer wrapper while UIKit still retains the underlying layer. A later Core Animation display pass can then call into a freed renderer context.
Backport Ghostty's callback-clearing fix, pin the existing custom-I/O source revision, and rebuild the device and simulator arm64 archives. The rebuild script now rejects source changes beyond the checked-in patch while allowing ignored build output, and it preserves the separately produced VT headers during archive refresh.
Native rebuild required: yes. Both checked-in iOS Ghostty archives changed.
Verification:
Verification used a focused native lifecycle harness, not the full T3 Code UI or a physical device.
Implemented with GPT-5.6 Sol xhigh in the Codex harness.
Note
Medium Risk
Changes native iOS terminal rendering teardown and vendored GhosttyKit binaries; incorrect callback handling could cause crashes or subtle rendering bugs on layer teardown.
Overview
Fixes a use-after-free in the vendored iOS Ghostty renderer when UIKit keeps the Metal layer after the wrapper is released: a later Core Animation display pass could still invoke a freed renderer via the layer callback.
The PR backports Ghostty’s upstream fix as
scripts/libghostty-ios-patches/0001-clear-display-callback-before-layer-release.patch, which clears the display callback inIOSurfaceLayer.releasebefore releasing the layer. Docs (README,THIRD_PARTY_NOTICES) now record the pinned fork revision and that patch.build-libghostty-ios16.shis tightened for reproducible rebuilds: it clones/checks out a pinned custom-I/O revision (default under~/.cache/t3code), applies the patch idempotently, and fails if the checkout has extra tracked or untracked changes beyond that patch. The Zig build runs with-j1, and header sync usesrsyncwithout--deleteso separately vendored VT headers are not wiped when refreshing archives. Checked-in device/simulator GhosttyKit binaries are expected to be rebuilt with this flow.Reviewed by Cursor Bugbot for commit 15472f6. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Clear
displayCallbackbefore releasingIOSurfaceLayerin Ghostty mobile build0001-clear-display-callback-before-layer-release.patch) that callssetDisplayCallback(null, null)before releasing the layer inIOSurfaceLayer.release, preventing a dangling callback during teardown.GhosttyKit.xcframeworkbinaries with the patch applied and updates build docs.~/.cache/t3code, apply the required patch automatically, and fail if the source tree has unexpected changes.GHOSTTY_SOURCE_DIRto the pinned cache path and compiles with-j1; existing local checkouts must be re-pinned or will fail validation.Macroscope summarized 15472f6.