`size_hint` overflow panic for unbounded source
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 58/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
Start with ChannelCountConverter::size_hint in src/conversions/channels.rs (around lines 94-99), where the size-hint arithmetic overflows when the source reports (usize::MAX, None). Then check MixerSource::size_hint in the mixer code, which passes through its sources' hints since #831. Reproduce by running the snippet from the issue in a debug build with a Zero source. Done means no overflow panic for unbounded sources and a sensible size hint, such as (0, None), that the maintainers agree on.
索引モデルが issue の本文から書いたものです。
説明
During development on the Zed codebase, I ran into a crash related to rodio. Below is what I was able to gather about the problem. Disclaimer: I am not very familiar with Rust and the code base and used AI help to arrive at this diagnosis (this report is still written by me though).
What I observed
ChannelCountConverter::size_hint panics when its source is unbounded (e.g. Zero). The converter does arithmetic on the size hint returned by the underlying source and if that size hint is (usize::MAX, None) we get a panic due to arithmetic overflow at https://github.com/RustAudio/rodio/blob/685e05765c2aff8fbb51e32cda5b18428d09ffbe/src/conversions/channels.rs#L94-L99
Reproducing example
Run the following code in a debug build (release builds don't panic but will silently report a wrong size hint).
let (mixer, source) = rodio::mixer::mixer(nz!(2), nz!(48000));
mixer.add(rodio::source::Zero::new(nz!(1), nz!(48000))); // mono into stereo
let mut source = source;
assert!(source.next().is_some());
let _ = source.size_hint(); // panics: attempt to add with overflow
The core issue seems to affect multiple versions, but in practice the MixerSource was probably able to hide this issue in the past. The MixerSource returned a (0, None) size hint (I checked versions v0.22.2 and v0.23.0), which doesn't cause an overflow. #831 introduced a change causing the mixer to pass-through the size hint of its underlying sources. If the source is Zero (like in the reproduction above), we get a panic. This currently affects master (685e0576).
This behavior can also be observed in 3ee9745 (which is the commit pinned by Zed, which led me to create this issue).
Suggested fix
I'm not familiar enough with the code base to identify the best way to fix this. To me the following seems plausible:
- Fix the
ChannelCountConverter::size_hintimplementation to gracefully handle infinite sources - Change
MixerSource::size_hintto return(0, None)for infinite sources to prevent other consumers from panicking when doing arithmetic on size hints when infinite sources are involved. This is its behavior in v0.22.2 and v0.23.0.
Related
#609 reported the sibling subtract overflow in the same function
#698 additionally suspected delay's size_hint
- 主要言語
- Rust
- スター
- 2.5k
- フォーク
- 338
- 平均マージ
- 1日 3時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RustAudio/rodio のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 73/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
-
WavDecoder::size_hint underflows (u32 wrap, ~4.29e9) after EOF, causes multi-GB Vec::collect() allocation対応中かも @marin-m が 9 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
RustAudio/rodio の issue をすべて見る
似ている issue
-
docs(metrics): replace stale src/metrics.rs line anchors in dashboard-metrics.md with symbol namesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
ci-cd desktop size:low telemetry-improvement telemetry-round-1
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
vfarcic/dot-agent-deck#2079 ·
メンテナーはふだん 1 日以内に返信
-
修改文件名时主键盘上的数字无法输入オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
qingjian-team/qingjian#894 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
rubys/roundhouse#1757 ·
-
enhancement user-priority/P3
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信