From 5dac719b2b5f72d9fbd417c839cb0154607950c0 Mon Sep 17 00:00:00 2001 From: Andreas Karatzas Date: Sun, 22 Mar 2026 00:37:29 -0500 Subject: [PATCH] [Bugfix] Handle libsndfile sf_error(NULL) race condition in audio fallback (#37782) Signed-off-by: Andreas Karatzas --- vllm/multimodal/media/audio.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vllm/multimodal/media/audio.py b/vllm/multimodal/media/audio.py index ae0a9f55b..47c2743bb 100644 --- a/vllm/multimodal/media/audio.py +++ b/vllm/multimodal/media/audio.py @@ -34,10 +34,14 @@ except ImportError: # Public libsndfile error codes exposed via `soundfile.LibsndfileError.code`, soundfile # being librosa's main backend. Used to validate if an audio loading error is due to a # server error vs a client error (invalid audio file). +# 0 = sf_error(NULL) race condition: when multiple threads fail sf_open_virtual +# concurrently, one thread may clear the global error before another reads it, +# producing code=0 ("Garbled error message from libsndfile" in soundfile). +# See: https://github.com/bastibe/python-soundfile/issues/479 # 1 = unrecognised format (file is not a supported audio container) # 3 = malformed file (corrupt or structurally invalid audio) # 4 = unsupported encoding (codec not supported by this libsndfile build) -_BAD_SF_CODES = {1, 3, 4} +_BAD_SF_CODES = {0, 1, 3, 4} def load_audio_pyav(