Conversation
Rodio 0.22.2's WAV decoder increments its read counter even when polled past EOF, which the resampler does at the end of the stream, so its u32 size_hint() underflows to ~2^32 (~2^32/3 after 48 kHz -> 16 kHz). Vec::collect() reserves from that hint whenever it runs out of capacity, so inputs whose sample count makes the Vec reallocate at that moment abort with "memory allocation of ~5727254732 bytes failed". Opus and other formats are affected too since they go through FFmpeg -> WAV. Collect the samples with plain pushes so that only the Vec's own amortized growth is used, and add a regression test covering the affected lengths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hello, Not sure to understand, in which cases does the bug you mention happen exactly? Is this something you have reported upstream? Do you have a test file to provide? Regards |
|
Hi, thanks for looking at this. When it happens: Cause: in Upstream: I haven't reported it to rodio yet, and I couldn't find an existing issue. 0.22.2 is still their latest release. I'm happy to open one there as well. Test file: attached as a zip. It's a 9.9 s mono 48 kHz sine tone with 474067 samples. You can also generate it yourself: import wave, struct, math
w = wave.open('songrec-crash-474067.wav', 'wb'); w.setnchannels(1); w.setsampwidth(2); w.setframerate(48000)
w.writeframes(b''.join(struct.pack('<h', int(8000*math.sin(i*0.05))) for i in range(474067))); w.close()Note: on a machine with a lot of RAM the kernel may simply grant the 5.7 GB. It's never actually touched, so nothing visibly breaks. I hit it on a 2 GB VPS. |
Rodio 0.22.2's WAV decoder increments its read counter even when polled past EOF, which the resampler does at the end of the stream, so its u32 size_hint() underflows to ~2^32 (~2^32/3 after 48 kHz -> 16 kHz). Vec::collect() reserves from that hint whenever it runs out of capacity, so inputs whose sample count makes the Vec reallocate at that moment abort with "memory allocation of ~5727254732 bytes failed". Opus and other formats are affected too since they go through FFmpeg -> WAV.
Collect the samples with plain pushes so that only the Vec's own amortized growth is used, and add a regression test covering the affected lengths.