JS_ThrowStackOverflow may overflow stack itself
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
Read build_backtrace() in quickjs.c around the stack-heavy JSCallSiteData allocation and the char buf[256] local mentioned in the issue. Trace how JS_ThrowStackOverflow() reaches backtrace construction, then assess the proposed approaches and their stack requirements. Done means throwing at the configured stack limit cannot itself overflow the physical stack.
由索引模型根据 Issue 内容生成。
描述
Hello,
QuickJS supports stack limiting with JS_SetMaxStackSize(), and many operations check remaining stack size before alloca() or calling functions. These checks call JS_ThrowStackOverflow(), which should throw corresponding exception. Obviously this exception has a stacktrace.
But the problem is that build_backtrace() function consumes huge amount of stack itself. For example, just this line implies x64 JSCallSiteData structs, each of them is x3 JSValue (+ 9 bytes + align), and each JSValue may be up to 16 bytes on x64 machine (depending on flags). This gives us 64 * aligned(3 * 16 + 9) = 3840 bytes. The full call chain performed to fill backtrace also includes other stack-heavy things, like char buf[256]. Since the exception itself was thrown because we've already reached stack limit, there is a risk of "physically" overflowing the stack if the limit was configured somewhat near the real stack size.
For now the only workaround is to set limit way lower than real stack size, but the needed spare space seems to be unpredictable.
Proposed solutions:
- Calculate and enforce maximum stack consumption for
JS_ThrowStackOverflow()and specify it in documentation; - Make
build_backtrace()and other corresponding functions less stack-heavy, moving every possible local value on (pre-allocated?) heap buffer; - Add some stack checks to throwing-related functions and fallback to skipping backtrace if building stacktrace is impossible.
- 主要语言
- C
- 星标
- 3.9k
- 派生
- 389
- 平均合并
- 4 天 1 小时
- 30 天内合并 PR
- 24
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
quickjs-ng/quickjs 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
quickjs-ng/quickjs#1836 ·
维护者通常 2 天内回复
-
Array.prototype.find frees an element twice when interrupted between iterations可能已有人在做 @josefguenther 于 15 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 73/100
quickjs-ng/quickjs#1792 · 1 条评论 ·
维护者通常 2 天内回复
-
Object.prototype.propertyIsEnumerable converts `this` before the property key可能已有人在做 @SomSamantray 于 11 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
quickjs-ng/quickjs#1772 ·
维护者通常 2 天内回复
-
Deserialization corrupts data or returns `undefined` when a RegExp precedes a shared object reference可能已有人在做 @Sree24-ui 于 14 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
quickjs-ng/quickjs#1771 · 2 条评论 ·
维护者通常 2 天内回复
-
难度 3/5 1-2 天 新手友好度 72/100
quickjs-ng/quickjs#1835 · 1 个 reaction ·
维护者通常 2 天内回复
查看 quickjs-ng/quickjs 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
valkey-io/valkey#4979 · 1 个 reaction ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
colbymchenry/codegraph#2770 ·
维护者通常 1 天内回复
-
area/ysql kind/enhancement priority/medium status/awaiting-triage
难度 2/5 1-3 小时 新手友好度 73/100
yugabyte/yugabyte-db#35578 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
test_announce_and_connect_via_dns binds a fixed port that other tests' nodes can be handed可能已有人在做 @ksedgwic 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 83/100
ElementsProject/lightning#9642 ·
维护者通常 2 天内回复