fix(rust): large BigInts bypass Limits::max_heap_bytes
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- rust
- 領域
- backend, performance, testing-qa
調査の方向性
Start with rust/crates/psychoscript/src/heap.rs and rust/crates/psychoscript/src/builtins/bigint.rs; the issue identifies the zero-size Kind::BigInt accounting and missing Value::Big traversal. Run the provided regression test to reproduce the excessive allocation, then trace heap charging and Walk::value for captured and own-property BigInts. Done means the test returns DiagnosticKind::MemoryLimitExceeded under the 2 MiB limit, with BigNum::Large limb storage and reachable BigInts charged to the heap.
索引モデルが issue の本文から書いたものです。
説明
Summary
In the Rust crate (psychoscript 0.1.3 / dev), Limits::max_heap_bytes does not count heap-allocated BigInts, allowing unbounded RSS growth under a small heap limit.
Cause
heap::object_bytes (rust/crates/psychoscript/src/heap.rs) explicitly returns 0 for Kind::BigInt(_):
Kind::Accessor(_) | Kind::Storage(_) | Kind::BigInt(_) => 0,
Additionally:
Walk::valueignoresValue::Big, so closure-capturedBigInts (Ref::Cell) and own-propertyBigInts onError/Closure/Native/Boundobjects are never visited during measurement.Vm::heap_big(rust/crates/psychoscript/src/builtins/bigint.rs) does not charge the extra limb byte length ofBigNum::Largetoward the allocation pacer (charge_heap).
Minimal Reproduction
use psychoscript::{DiagnosticKind, Limits, Runtime};
#[test]
fn large_bigints_bypass_max_heap_bytes() {
let rt = Runtime::make().limits(Limits {
max_heap_bytes: Some(2 * 1024 * 1024),
..Limits::default()
});
let code = "const base = 1n << 1_000_000n; const a = []; for (let i = 0; i < 100; i++) a.push(base + BigInt(i)); return a.length";
let outcome = rt.execute(code);
assert_eq!(
outcome.result.unwrap_err().kind,
DiagnosticKind::MemoryLimitExceeded
);
}
Observed: Completes with Ok(100) and grows process RSS by ~115 MiB under a 2 MiB max_heap_bytes limit (similarly when captured by closures a.push(() => x) or stored on function/error properties).
Expected: Stops with DiagnosticKind::MemoryLimitExceeded.
- 主要言語
- Rust
- スター
- 470
- フォーク
- 11
- 平均マージ
- 4時間 10分
- マージ済み PR(30日)
- 89
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
anomalyco/psychoscript のほかの issue
-
fix(rust): Returned::Block deadlocks single-threaded async executors under execute_async対応中かも @brxs が 2 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
anomalyco/psychoscript#110 ·
メンテナーはふだん 1 日以内に返信
-
fix(rust): duplicate fresh strings bypass Limits::max_heap_bytes対応中かも @brxs が 2 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
anomalyco/psychoscript#109 ·
メンテナーはふだん 1 日以内に返信
-
Importing psychoscript throws RangeError in Safari (WebKit/JavaScriptCore)対応中かも @vibdev が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
anomalyco/psychoscript#100 ·
メンテナーはふだん 1 日以内に返信
-
Runs fail with `setImmediate is not defined` in browsers and Convex's runtime once a program runs longer than ~1 ms対応中かも @fengqiaoqu が 2 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
anomalyco/psychoscript#82 ·
メンテナーはふだん 1 日以内に返信
anomalyco/psychoscript の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
storytold/filmcraft#5386 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
enhancement in-progress
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100