[p5.js 2.0+ Bug Report]: randomGaussian() leaks its spare value across p5 instances, breaking seeded determinism
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 38/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- frontend
調査の方向性
src/math/random.js から始めて、既存のスキップされているインスタンスモードの独立性テストを確認します。2 つの p5 インスタンスでシード付きの呼び出しを交互に実行する状況を再現し、その後、関連する乱数テストを実行します。インスタンスが独立した決定論的なシーケンスを生成し、回帰テストに合格すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Most appropriate sub-area of p5.js?
Math
p5.js version
2.x main (4b096e2)
Actual vs expected behavior
The randomSeed() reference promises that a constant seed "makes these functions produce the same results each time a sketch is run", explicitly naming randomGaussian(). That breaks as soon as two p5 instances exist on a page.
randomGaussian() uses the Marsaglia polar method, which produces values in pairs. The flag that says "a spare value is cached" lives on the instance (this._gaussian_previous), but the spare value itself lives in module scope (let y2 = 0; in src/math/random.js). With two instances, B's spare overwrites A's, and A's next call returns B's value.
Executed repro (both instances seeded, one interleaved call on instance B):
A alone : -0.2050, -0.3410, 0.3986, -1.4309
A interleaved: -0.2050, -0.9404, 0.3986, -1.4309
Same seed, different sequence. The existing test suite even contains a skipped "instance mode / should be independent" block asserting exactly this independence. PR #1681 (2015) made _gaussian_previous per-instance but left y2 module-scoped, which is the remaining half of that fix.
Steps to reproduce
Outputs above are from executed runs against main, two instances sharing the prototype as in instance mode.
Note
I have a fix ready (store the spare as this._gaussian_y2) with a regression test, mutation-tested against main. Filing for approval first per the contributing guide; will open the PR once approved.
- 主要言語
- JavaScript
- スター
- 24.1k
- フォーク
- 3.9k
- 平均マージ
- 3日 10時間
- マージ済み PR(30日)
- 30
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
processing/p5.js のほかの issue
-
[p5.js 2.0+ Bug Report]: SVG importer does not respect preserveAspectRatio="none" for <symbol>/<use>対応中かも @Danyccsf が 2 日前に担当しました。 オープンArea:Core p5.js 2.0+
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
processing/p5.js#9257 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
Add unit tests for noiseDetail()対応中かも @Pcmhacker-piro が 4 日前に担当しました。 オープンArea:Math Enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
processing/p5.js#9253 ·
メンテナーはふだん 2 日以内に返信
-
[p5.js 2.0+ Bug Report]: storeItem() validation branches are missing `return`, so bad input throws a TypeError or is stored anyway対応中かも @iUjjwalRaj が 4 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
processing/p5.js#9242 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
processing/p5.js#9241 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
[p5.js 2.0+ Bug Report]: Typo in Spanish reference documentation for ellipseMode()再び着手できるかも @cgutierrezval が 7 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンInternationalization p5.js 2.0+
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
processing/p5.js#9231 · コメント 3 件 ·
メンテナーはふだん 2 日以内に返信
processing/p5.js の issue をすべて見る
似ている issue
-
bug release:v5.56
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Jason-Vaughan/TangleClaw#2270 ·
メンテナーはふだん 1 日以内に返信
-
priority: medium tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
LeeAdcock/robocodeJs.com#411 ·
メンテナーはふだん 1 日以内に返信
-
status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
mastra-ai/mastra#26635 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
chore good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
pedrorchagas/blog-api#21 ·