Rust codegen: Map::set mutates a shared ValueMap in place, causing use-after-free on ValueRef::property borrows
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with valdi_core/src/valdi_core/rust/collections.rs and trace Map::set, then read the RustValdi.cpp functions valdi_rust_value_ref_get_property and valdi_rust_value_map_set described in the issue. Check how map handles share their ValueMap and how references are kept valid during mutation. Done means Map::set uses copy-on-write so changes do not mutate shared maps or invalidate live ValueRef::property borrows.
索引モデルが issue の本文から書いたものです。
説明
Found while reviewing https://github.com/Snapchat/Valdi/pull/211 (native Rust code generation). Not blocking that PR.
Map::set mutates a shared ValueMap in place, causing use-after-free on ValueRef::property borrows
File: valdi_core/src/valdi_core/rust/collections.rs
When a ValueRef pointing to a map entry is live (via ValueRef::property) alongside a Map sharing the same underlying ValueMap, calling Map::set can reallocate the map's backing storage and leave that ValueRef dangling (Use-After-Free). The problem starts in Map::set in collections.rs, which mutates the ref-counted ValueMap in place despite Map::clone, Map::to_valdi, and Map::from_valdi all sharing the same Ref<Valdi::ValueMap>.
In RustValdi.cpp, valdi_rust_value_ref_get_property returns &iterator->second — a direct pointer into ValueMap's phmap::flat_hash_map bucket array — as a ValueRef<'a>, while valdi_rust_value_map_set calls map->insert_or_assign(...) directly on the shared map. Inserting enough keys through one Map handle rehashes the FlatMap and frees the old buckets while another Map, Value, or borrowed ValueRef still references them, causing Use-After-Free in safe Rust as well as unexpected mutation across clones.
Make Map::set copy-on-write (clone the ValueMap into a fresh ValdiRustHandle when the handle or underlying ValueMap is shared) so mutating &mut Map never invalidates other handles or borrowed ValueRefs.
- 主要言語
- C++
- スター
- 16.4k
- フォーク
- 539
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Snapchat/Valdi のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
Rust codegen: RustMethodResolver fails to unwrap .nullable on optional interface/module methodsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
RTL-SDR: re-enumerating while streaming removes the in-use entry from the device selection dialog対応中かも @dpc00 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
throneproj/Throne#2227 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepseek-ai/DeepGEMM-Ascend#49 ·
メンテナーはふだん 1 日以内に返信