CommandCodeAI / CommandCodeAI/command-code

RuntimeError: memory access out of bounds in yoga-layout WASM during "Loading sessions"

未关闭
#839 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
没有语言数据
星标
4k
派生
350
PR 合并指标
30 天内没有已合并 PR

描述

Crash Report

Error
✖ CRITICAL: Uncaught Exception!
✖ ERROR → RuntimeError
ℹ REASON → memory access out of bounds
Stack Trace
RuntimeError: memory access out of bounds
    at wasm://wasm/000460e2:wasm-function[215]:0xd5ef
    at wasm://wasm/000460e2:wasm-function[185]:0xcf8c
    at X.getComputedWidth (yoga-wasm-base64-esm.js:33:52)
    at renderer (renderer.js:32:49)
    at onRender (ink.js:348:56)
    at debounce (debounce.mjs:12:17)
    at invoke (debounce.mjs:45:9)
    at onTimerEnd (debounce.mjs:51:17)
    at Timeout._onTimeout (debounce.mjs:59:4)
Environment
  • Command Code version: 1.53.0
  • Node.js: v26.1.0 (via nvm)
  • yoga-layout: 3.2.1
  • ink: 7.1.0
  • OS: Linux
Reproduction

This crash occurs during "Loading sessions…" — it happens intermittently when the app starts up and loads saved sessions.

Trace ID

3a1270ebb1c389e7db6257397a21f5e0

Analysis

The crash happens in renderer.js:32 when node.yogaNode.getComputedWidth() is called on a yoga node whose WASM memory has already been freed. This appears to be a race condition between:

  1. React's reconciler destroying nodes (calling freeRecursive() via cleanupYogaNode in removeChild/removeChildFromContainer)
  2. The debounced render callback still trying to traverse the node tree and compute layout on the now-deallocated WASM node

This is triggered when rapid state changes occur (e.g., mounting/unmounting components during "Loading sessions"), causing a yoga node to be freed in one tick while the throttled renderer still holds a reference.

Suggested Fix

Add a guard in renderer.js to check whether yogaNode is still valid before calling getComputedWidth(), or wrap the WASM call in a try-catch to handle freed nodes gracefully.

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

复现启动期间显示“Loading sessions…”时的间歇性崩溃。阅读 renderer.js:32 以及 removeChild 和 removeChildFromContainer 中的 cleanupYogaNode 路径,然后追踪经过防抖的渲染回调如何保留节点。完成标准是:读取布局时,加载 session 不再触发 WASM 内存访问崩溃。

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, node.js, wasm
领域
cli
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
52/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。