Android jsi: console timers map is shared by every runtime thread without a lock
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue nà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
- 53/100
Hướng nghiên cứu
Read NativeScript/runtime/android/jsi/modules/console/Console.h and Console.cpp, tracing createConsole(), the console.time and console.timeEnd callbacks, and onDisposeRuntime(). Reproduce the race with the worker stress test described for #93, using HWASan if available. Done when creating and disposing runtimes during timer calls no longer races on the shared map; the issue lists a mutex or per-runtime state as possible approaches.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
On jsi, Console::s_rtToConsoleTimersMap (NativeScript/runtime/android/jsi/modules/console/Console.{h,cpp}) is a single, process-wide std::map that every runtime reads and writes from its own thread with no lock:
- insert:
createConsole()→s_rtToConsoleTimersMap.emplace(rt.identity(), ...), when each runtime starts; - find: the
console.time/console.timeEndcallbacks; - erase:
onDisposeRuntime(), when each runtime is disposed.
When workers start or stop while another runtime is using the map, one thread rebalances the tree while another walks it. That is a data race and can corrupt the heap or crash.
How it was found
The worker stress test used for #93 (12 workers at a time, created and terminated after 20–300 ms, with JS and Java GC forced throughout). HWASan was turned on locally; it is off by default. On jsi, this map crashed every stress run.
Expected
Creating or disposing one runtime can't corrupt another runtime's console timers. Possible fixes:
- guard the map with a mutex;
console.timeis not a hot path; - or make the timers per-runtime state owned by the
Consoleinstance or the runtime.
Environment
- Branch:
android-react-nativeat 64c7fed0 - Emulator: Android API 36, arm64, debug build of
platforms/android/test-appwith HWASan enabled locally - Binding layer: jsi
- Ngôn ngữ chính
- C++
- Star
- 27
- Fork
- 4
- Merge trung bình
- 16 giờ 48 phút
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
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 NativeScript/runtimes
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
NativeScript/runtimes#100 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
NativeScript/runtimes#99 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 55/100
NativeScript/runtimes#98 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
NativeScript/runtimes#94 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
NativeScript/runtimes#93 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của NativeScript/runtimes
Issue tương tự
-
bug-unconfirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Extended search mode does not find escape sequences (\t, \n, \r...)Có thể đã có người làm @CyrilB1531 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 87/100
dail8859/NotepadNext#1181 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A-tools P-low S-blocked task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
☢️ Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenAtomFoundation/pikiwidb#3309 ·
-
audit(c2): add_project_arguments('/experimental:c11atomics', language: ['c', 'cpp']) for MS (C2-13)Đang mởhygiene type:refactor
Độ 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