Android: per-runtime statics are read and written from runtime threads without a lock
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
Start by reading the listed Android N-API and JSI files, then compare their shared static maps and APP_ROOT_FOLDER_PATH assignments with the tns::ConcurrentMap usage mentioned in the issue and the Hermes env_to_jsr_mutex guard. Check how the quickjs and primjs backends store env_to_jsr_cache as well. Done means concurrent runtime creation and disposal cannot corrupt state another runtime reads; the issue names no tests to run.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
Several process-wide statics hold one entry per runtime, or one value set by every runtime. Each runtime reads and writes them from its own thread, with no lock. When workers start or stop while other runtimes are running, these are data races of the same kind as #93: a hash table can rehash under a concurrent reader, and a std::string can be reallocated under a concurrent reader.
| Static | Where | Written | Read |
|---|---|---|---|
JSR::env_to_jsr_cache (std::unordered_map) |
NativeScript/napi/v8/jsr.cpp |
js_create_napi_env, js_free_napi_env |
js_lock_env / js_unlock_env |
MetadataNode::s_arrayObjects (robin_hood::unordered_map) |
NativeScript/ffi/jni/{napi,jsi}/metadata/MetadataNode.cpp |
first array-constructor lookup in each runtime; erased on dispose | every array-constructor lookup |
envToPersistentSmartJSONStringify / rtToPersistentSmartJSONStringify (robin_hood::unordered_map) |
NativeScript/ffi/jni/{napi,jsi}/global/GlobalHelpers.cpp |
first JsonStringifyObject in each runtime; erased on dispose |
every JsonStringifyObject |
Constants::APP_ROOT_FOLDER_PATH (std::string) |
NativeScript/ffi/jni/{napi,jsi}/constants/Constants.cpp |
assigned in Runtime::Init of every runtime (NativeScript/runtime/android/{napi,jsi}/Runtime.cpp) |
module resolution, stack traces, MetadataNode origins, inspector |
The quickjs and primjs backends keep env_to_jsr_cache in a tns::SimpleMap, which has no lock either. The hermes backend already guards its copy with env_to_jsr_mutex.
MetadataNode::s_metadata_node_cache and (with #96) ArgConverter's long-conversion cache already use tns::ConcurrentMap, which is the pattern to follow for the maps.
Expected
Creating or disposing one runtime can't corrupt state another runtime is reading. Possible fixes:
- the per-runtime maps move to
tns::ConcurrentMapwith theGet/Insert/Removepattern used in #96, or become per-runtime state; APP_ROOT_FOLDER_PATHis set once per process, since every runtime computes the same value (filesRoot + "/app/"), or is guarded.
Environment
- Branch:
android-react-nativeat 64c7fed0 - Found by reading the code while fixing #93; these were not seen crashing on their own.
Related: #93, #96, and #97 and #98 (the console timer maps).
- Vorherrschende Sprache
- C++
- Sterne
- 27
- Forks
- 4
- Ø Merge
- 16 Std. 48 Min.
- Gemergte PRs (30 T.)
- 4
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus NativeScript/runtimes
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
NativeScript/runtimes#100 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 1-2 Tage Anfängerfreundlichkeit 55/100
NativeScript/runtimes#98 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 53/100
NativeScript/runtimes#97 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
NativeScript/runtimes#94 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
NativeScript/runtimes#93 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in NativeScript/runtimes
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
NVIDIA-Omniverse/PhysX#590 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
apache/rocketmq-clients#1469 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 9 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
compiler-explorer/compiler-explorer#9402 ·
Maintainer antworten meist innerhalb von 1 Tag
-
自定义颜色添加为常用颜色Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
mg-chao/snow-apps#2227 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag