Android napi: console.time / console.timeEnd dereference a missing map entry
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
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
Hướng nghiên cứu
Start with NativeScript/runtime/android/napi/modules/console/Console.cpp and compare the napi console creation and callbacks with createConsole() in the jsi tree. Reproduce with console.time("x"); console.timeEnd("x"); on a napi engine, then check that per-environment timer state is initialized, missing entries return safely, and access is synchronized. Done means the repro measures and logs elapsed time without undefined behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
On napi, console.time and console.timeEnd dereference a map iterator that is always end(). Console::s_envToConsoleTimersMap (NativeScript/runtime/android/napi/modules/console/Console.cpp) is never given an entry for any napi_env, so:
auto it = Console::s_envToConsoleTimersMap.find(env);
if (it == Console::s_envToConsoleTimersMap.end()) {
// throw?
}
...
it->second.insert(std::make_pair(label, timeStamp)); // it == end()
timeCallback inserts into it->second with it == end(), which is undefined behaviour. timeEndCallback copies it->second by value and later erases from it, which is undefined for the same reason.
The jsi tree does not have this bug: its createConsole() emplaces an entry per runtime, and its callbacks return early when the entry is missing.
Repro
On any napi engine:
console.time("x");
console.timeEnd("x");
The result depends on the heap layout: anything from nothing visible to a corrupted heap or a crash.
Expected
console.time / console.timeEnd measure and log the elapsed time. Fix: create the per-env entry when the console is created, as jsi does, and bail out if it is missing. The map has the same cross-thread race as the jsi one, so it needs the same synchronization.
Environment
- Branch:
android-react-nativeat 64c7fed0 - Binding layer: napi (all engines)
- 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 3-5 ngày Mức phù hợp với người mới 53/100
NativeScript/runtimes#97 · 1 bình luận ·
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
Độ 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
-
enhancement Ready for final check
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
mpogue2/SquareDesk#1818 · 1 bình luận ·
-
launch-client --save-creds creates creds/<account>/ with mode 755, not 700Có thể đã có người làm @metis-sprock đã nhận hôm nay. Đang mởbacklog bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
EchoTools/nevr-runtime#1471 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
docs: Page not found?Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
iamankushpandit/Gume#231 ·
Maintainer thường phản hồi trong vòng 1 ngày