Android jsi: console timers map is shared by every runtime thread without a lock
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 53/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- C++
- スター
- 27
- フォーク
- 4
- 平均マージ
- 16時間 48分
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
NativeScript/runtimes のほかの issue
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
NativeScript/runtimes#100 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
NativeScript/runtimes#99 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 1〜2日 初心者へのやさしさ 55/100
NativeScript/runtimes#98 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
NativeScript/runtimes#94 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
NativeScript/runtimes#93 ·
メンテナーはふだん 1 日以内に返信
NativeScript/runtimes の issue をすべて見る
似ている issue
-
audit(c2): add_project_arguments('/experimental:c11atomics', language: ['c', 'cpp']) for MS (C2-13)オープンhygiene type:refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
sandialabs/Fenix#172 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
rocketride-org/rocketride-server#2886 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
scp-fs2open/fs2open.github.com#7953 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
SteveMacenski/slam_toolbox#907 ·