JS_ThrowStackOverflow may overflow stack itself
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C
- Star
- 3.9k
- Fork
- 389
- Merge trung bình
- 4 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 24
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của quickjs-ng/quickjs
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
quickjs-ng/quickjs#1836 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Array.prototype.find frees an element twice when interrupted between iterationsCó thể đã có người làm @josefguenther đã nhận 15 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
quickjs-ng/quickjs#1792 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Object.prototype.propertyIsEnumerable converts `this` before the property keyCó thể đã có người làm @SomSamantray đã nhận 10 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
quickjs-ng/quickjs#1772 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Deserialization corrupts data or returns `undefined` when a RegExp precedes a shared object referenceCó thể đã có người làm @Sree24-ui đã nhận 14 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
quickjs-ng/quickjs#1771 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
quickjs-ng/quickjs#1835 · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của quickjs-ng/quickjs
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug Status: Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Remove unused FVS_* macrosĐang mởinterpreter-core type-feature
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[onnx] update to 1.22.0Đang mởcategory:port-update
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Update OpenBSD CI to OpenBSD 8.0 and vmactions/openbsd-vm v1.4.9Có thể đã có người làm @hyoklee đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 2 ngày