`size_hint` overflow panic for unbounded source
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 58/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- audio-video-rtc
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Rust
- Stelle
- 2.5k
- Fork
- 338
- Merge medio
- 1g 3h
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di RustAudio/rodio
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 73/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
-
WavDecoder::size_hint underflows (u32 wrap, ~4.29e9) after EOF, causes multi-GB Vec::collect() allocationForse già presa @marin-m l’ha presa 9 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
Tutte le issue di RustAudio/rodio
Issue simili
-
docs(metrics): replace stale src/metrics.rs line anchors in dashboard-metrics.md with symbol namesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
ci-cd desktop size:low telemetry-improvement telemetry-round-1
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
vfarcic/dot-agent-deck#2079 ·
I maintainer di solito rispondono entro 1 giorno
-
修改文件名时主键盘上的数字无法输入Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
qingjian-team/qingjian#894 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
rubys/roundhouse#1757 ·
-
enhancement user-priority/P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno