Rust codegen: Empty interned strings cause a null pointer dereference in valdi_rust_value_ref_get_string

オープン 初心者向け
#236 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp, rust

調査の方向性

valdi_core/src/valdi_core/cpp/Marshalling/RustValdi.cpp の valdi_rust_value_ref_get_string から始めて、isInternedString() の分岐を調べます。空の interned string を使って null pointer の経路を再現し、issue に記載された null check と empty-slice fallback を追加します。空文字列でクラッシュしなくなり、既存の Rust string 変換の動作が維持されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Found while reviewing https://github.com/Snapchat/Valdi/pull/211 (native Rust code generation). Not blocking that PR.

Empty interned strings cause a null pointer dereference in valdi_rust_value_ref_get_string

File: valdi_core/src/valdi_core/cpp/Marshalling/RustValdi.cpp

Reading an empty interned string from Rust (such as "" passed from TypeScript or constructed via Value::from_string("")) crashes the process with a null pointer dereference. The crash starts in valdi_rust_value_ref_get_string inside the isInternedString() branch when string->toStringView() is called.

Because StringCache::makeString represents an empty string as a default StringBox with no InternedStringImpl allocation, Value stores _isShared = false and a null pointer while still setting ValueType::InternedString. Calling getTypedRef<Valdi::InternedStringImpl>() returns nullptr, so dereferencing string on the next line segfaults.

Check string != nullptr before calling string->toStringView(), falling back to Valdi::makeRustSlice("").

主要言語
C++
スター
16.4k
フォーク
539
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Snapchat/Valdi のほかの issue

Snapchat/Valdi の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。