Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Android jsi: console timers map is shared by every runtime thread without a lock

Đang mở
#97 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
android, cpp
Lĩnh vực
backend

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ả

bug

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.timeEnd callbacks;
  • 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.time is not a hot path;
  • or make the timers per-runtime state owned by the Console instance or the runtime.

Environment

  • Branch: android-react-native at 64c7fed0
  • Emulator: Android API 36, arm64, debug build of platforms/android/test-app with 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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NativeScript/runtimes

Tất cả issue của NativeScript/runtimes

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.