A native program crashes with SIGSEGV when a string or JSON builder grows past 4 MiB
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 22/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- c, linux, typescript
调研方向
Start in scr_sa_run_move in scr_alloc.c, where the run is moved with mremap(..., MREMAP_MAYMOVE | MREMAP_FIXED, q) and the fallback memcpy(q, p, have) runs after a failed call. Reproduce with the 1760 x 2400-character JSON snippet from the issue, which should exit 139 today. Done means that snippet prints 4229281 and the slice without crashing, and that the fallback no longer writes to unmapped memory. PR #3643 already targets this, so review or coordinate there before starting a second fix.
由索引模型根据 Issue 内容生成。
描述
A compiled program dies with SIGSEGV when a string builder grows past 4 MiB, in scr_sa_run_move's fallback copy. Node runs the same program.
Environment
- scriptc 0.4.12 from npm (the release's
@scriptc/compilerunder Node, linking@scriptc/runtime-linux-x64-gnu); upstreammainat 3198190fb3 has the same code. - Linux 6.8.0 x86_64, glibc 2.39.
What happens
const lines: string[] = [];
for (let i = 0; i < 1760; i++) lines.push("x".repeat(2400));
const text = JSON.stringify(lines);
console.log(String(text.length));
console.log(text.slice(0, 8));
Node prints 4229281 and ["xxxxxx. The native build prints nothing and exits 139.
The backtrace from an unstripped build of a larger app that hit it (resuming a 5 MB transcript, which became one JSON text):
#0 __memcpy_evex_unaligned_erms
#1 scr_sa_run_move () at scr_alloc.c
#2 scr_mem_realloc_ref ()
#3 scr_str_regrow ()
#4 scr_jb_grow ()
#5 scr_jb_put_json_str ()
#6 scr_dyn_json_write ()
...
#9 scr_json_stringify_with ()
At the fault: p=0x387c00000, q=0x388400000, have=0x800000, n=0x800019. info proc mappings showed an unmapped hole at exactly [0x388400000, 0x388c00000), which is q to q + have.
Cause
scr_sa_run_move moves the run with mremap(p, have, have, MREMAP_MAYMOVE | MREMAP_FIXED, q). When the old run spans two mappings, the call fails. On Linux a failed MREMAP_FIXED has already unmapped the destination range, so the fallback memcpy(q, p, have) writes into unmapped memory.
#3595 (the native CLI segfaulting on a large program) may be the same crash, since the CLI builds large strings too. I have not checked that.
- 主要语言
- TypeScript
- 星标
- 6.6k
- 派生
- 216
- 平均合并
- 9 小时 35 分钟
- 30 天内合并 PR
- 775
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
vercel-labs/scriptc 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
vercel-labs/scriptc#3979 ·
维护者通常 1 天内回复
-
Support undici 8.x request() through the built-in implementation可能已有人在做 @younggglcy 于 1 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 35/100
vercel-labs/scriptc#3894 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 22/100
vercel-labs/scriptc#3613 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 42/100
vercel-labs/scriptc#3605 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 12/100
vercel-labs/scriptc#3595 ·
维护者通常 1 天内回复
查看 vercel-labs/scriptc 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
milind-soni/OpenMausBot#6730 ·
维护者通常 1 天内回复
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)未关闭area: @angular/build
难度 2/5 1-3 小时 新手友好度 65/100
angular/angular-cli#34764 ·
维护者通常 1 天内回复
-
status/need-triage
难度 2/5 1-3 小时 新手友好度 76/100
google-gemini/gemini-cli#30384 · 1 条评论 ·
维护者通常 1 天内回复
-
P2
难度 1/5 1 小时以内 新手友好度 84/100
维护者通常 1 天内回复
-
area:image documentation good first issue
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复