Collecting WeakMap keys requires multiple GC passes
Maintainer thường phản hồi trong vòng 3 ngà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
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- c
Hướng nghiên cứu
Start with the attached weakmap_gc_repro.c and run it using the build commands in the issue to confirm both cases. Then trace QuickJS's WeakMap and weak-reference handling in the GC; the issue does not name source files or tests, so locate the relevant code and existing GC tests. Done means the self-referencing key is collected and the chain of keys is freed after a fixed number of GC passes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Issue
I think I've found two bugs related to weak references / WeakMap handling by the GC.
(1) An entry whose value references its own key is never collected while the WeakMap is alive.
/* Case 1: the value references its own key. */
(function () {
var key = {};
map.set(key, { backRef: key });
globalThis.selfRef = new WeakRef(key);
})();
Expected result:
keyis collected after one pass of the GC
Actual result:
keyis never collected by the GC but should be collected on the first pass.
(2) A chain of entries (each value references the next entry's key) takes n JS_RunGC() calls to free
/* Case 2: a chain of 20 entries; each value references the next key. */
(function () {
var key = {};
for (var i = 0; i < 20; i++) {
var next = {};
map.set(key, { child: next });
key = next;
}
globalThis.chainTail = new WeakRef(key);
})();
Expected result:
- All 20 keys is collected after a fixed number (ideally one) passes of the GC.
Actual result:
- Collecting
nkeys appears to requirenpasses of the GC.
Repro
Here's a program that reproduces the issue. Compile it like this:
quickjs $ make libquickjs.a
quickjs $ cc -O2 -I. weakmap_gc_repro.c libquickjs.a -lm -lpthread -o weakmap_gc_repro
quickjs $ ./weakmap_gc_repro
- Ngôn ngữ chính
- C
- Star
- 11.1k
- Fork
- 1.2k
- Merge trung bình
- 11 giờ 20 phút
- Pull request đã merge (30 ngày)
- 1
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 bellard/quickjs
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Failed Build/Compile On CygwinĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 58/100
bellard/quickjs#575 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Update to Unicode 18.0.0Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 50/100
bellard/quickjs#559 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Security findings: BigInt interrupt-bypass CPU DoS (verified) and 5 other issues — commit 04be246Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của bellard/quickjs
Issue tương tự
-
Độ khó 2/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 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
eunomia-bpf/bpfix#7 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
python-pillow/Pillow#10370 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày