Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

WASM memory corruption after freeing terminal that processed multi-codepoint grapheme clusters

Đang mở
#141 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript, wasm
Lĩnh vực
devtools, web-dev

Hướng nghiên cứu

Bắt đầu bằng cách chạy repro.ts với Bun, sau đó kiểm tra terminal.free và lệnh gọi ghostty_terminal_write được hiển thị tại ghostty-web.js:145. So sánh việc giải phóng một terminal sau văn bản gồm một codepoint với việc giải phóng một terminal sau các cụm grapheme được liệt kê; hoàn tất khi các lệnh gọi createTerminal() và write() tiếp theo không còn gặp lỗi truy cập bộ nhớ ngoài phạm vi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Environment

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).

Ngôn ngữ chính
TypeScript
Star
2.9k
Fork
174
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của coder/ghostty-web

Tất cả issue của coder/ghostty-web

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.