WASM memory corruption after freeing terminal that processed multi-codepoint grapheme clusters
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- typescript, wasm
Direzione di ricerca
Inizia eseguendo repro.ts con Bun, quindi esamina terminal.free e la chiamata a ghostty_terminal_write mostrata in ghostty-web.js:145. Confronta la liberazione di un terminale dopo testo costituito da un singolo codepoint con la liberazione di un terminale dopo i cluster di grafemi elencati; il lavoro è completato quando le chiamate successive a createTerminal() e write() non causano più un accesso alla memoria fuori dai limiti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Environment
- OS: macOS 15.4 (Darwin 25.2.0, arm64)
- Package: ghostty-web@0.4.0
- Runtime: Bun 1.3.9
Description
Calling terminal.free() after writing any multi-codepoint grapheme cluster (flag emoji, skin tone modifiers, ZWJ sequences, keycap sequences) corrupts the shared WASM memory. All subsequent createTerminal() + write() calls crash with an out-of-bounds memory access.
Single-codepoint characters (ASCII, CJK, simple emoji like 😀) do not trigger the bug.
Reproduction
import { Ghostty } from "ghostty-web";
const ghostty = await Ghostty.load();
const term1 = ghostty.createTerminal(80, 24);
term1.write("👋🏽"); // Any multi-codepoint grapheme cluster
term1.free(); // ← corrupts WASM memory
const term2 = ghostty.createTerminal(80, 24);
term2.write("Hello"); // ← crashes
Save as repro.ts and run with bun run repro.ts.
Characters that trigger the bug
All multi-codepoint grapheme clusters:
- Flag emoji: 🇺🇸 🇬🇧 🇯🇵 (regional indicator pairs)
- Skin tone: 👋🏽 (base + Fitzpatrick modifier)
- ZWJ families: 👨👩👧 (ZWJ sequences)
- Keycap: 1️⃣ (digit + VS16 + combining enclosing keycap)
Characters that do NOT trigger the bug
Single-codepoint characters:
- ASCII:
Hello - CJK:
漢字 - Simple emoji:
😀(single codepoint, no modifiers)
Error Output
RuntimeError: Out of bounds memory access (evaluating 'this.exports.ghostty_terminal_write(this.handle, g, B.length)')
at write (ghostty-web.js:145:64)
The crash is in ghostty_terminal_write — the WASM linear memory has been corrupted by the preceding free(), so the next write() accesses invalid memory.
Impact
This blocks using ghostty-web for multi-terminal workflows (test suites, terminal pools, tab management) where terminals are created, used, and freed in sequence. If any terminal processes grapheme clusters before being freed, all subsequent terminals in the same WASM instance are broken.
Workaround
Don't free terminals that have processed multi-codepoint grapheme clusters. Leak them instead:
// Instead of term.free(), just abandon the reference
// term.free() // ← skip this
term = null;
Or use one process per terminal (expensive but avoids shared WASM state).
- Lingua principale
- TypeScript
- Stelle
- 2.9k
- Fork
- 174
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di coder/ghostty-web
-
attachCustomKeyEventHandler inverts xterm.js's return-value contract (silently swallows all input) Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
coder/ghostty-web#192 ·
-
A single throw inside render() permanently stops the render loop, and a consumer cannot restart it Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 65/100
coder/ghostty-web#189 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
coder/ghostty-web#188 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
coder/ghostty-web#187 ·
-
Hyperlink arena exhaustion (StringAllocOutOfMemory) spins the write path instead of degrading Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
coder/ghostty-web#186 · 1 commento ·
Tutte le issue di coder/ghostty-web
Issue simili
-
bug(cli): hapi doctor inline-media prints a fabricated B:\ helper-script path in packaged installs Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Crush Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
catppuccin/catppuccin#3125 ·
-
Add a SECURITY.md Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
ElementsProject/cln-application#167 · 1 commento · 1 reazione ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Quantco/pnpm-licenses#17 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100