Android napi: console.time / console.timeEnd dereference a missing map entry
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 55/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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)
- 主要言語
- 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 3〜5日 初心者へのやさしさ 53/100
NativeScript/runtimes#97 · コメント 1 件 ·
メンテナーはふだん 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
-
難易度 1/5 1時間未満 初心者へのやさしさ 66/100
madskristensen/FileIcons#385 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
microsoft/SysmonCommon#26 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
espressif/esp-matter#1913 ·
-
bug priority: low
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
chipsalliance/verible#2644 ·