Skip to content

[Bugfix] Handle libsndfile sf_error(NULL) race condition in audio fallback#37782

Merged
Isotr0py merged 2 commits intovllm-project:mainfrom
ROCm:akaratza_fix_entrypoints_audio
Mar 22, 2026
Merged

[Bugfix] Handle libsndfile sf_error(NULL) race condition in audio fallback#37782
Isotr0py merged 2 commits intovllm-project:mainfrom
ROCm:akaratza_fix_entrypoints_audio

Conversation

@AndreasKaratzas
Copy link
Copy Markdown
Collaborator

@AndreasKaratzas AndreasKaratzas commented Mar 22, 2026

Fixes regression after: #37058

When multiple threads concurrently fail sf_open_virtual() on unsupported formats (e.g. MP4 bytes passed as audio), sf_error(NULL) may return 0 instead of the actual error code due to a global-state race in libsndfile. This caused code=0 LibsndfileError ("Garbled error message from libsndfile") to bypass the pyav fallback in load_audio(), crashing requests that send video bytes as audio_url (e.g. audio-in-video). In this PR, 0 is added to _BAD_SF_CODES so the pyav fallback triggers for this case.

There is also an upstream soundfile issue: bastibe/python-soundfile#479

Testing

  • pytest -s -v tests/entrypoints/openai/chat_completion/test_audio_in_video.py::test_online_audio_in_video_interleaved

cc @kenroche

…lback

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
@AndreasKaratzas AndreasKaratzas added the rocm Related to AMD ROCm label Mar 22, 2026
@github-project-automation github-project-automation Bot moved this to Todo in AMD Mar 22, 2026
@mergify mergify Bot added multi-modality Related to multi-modality (#4194) bug Something isn't working labels Mar 22, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a race condition in libsndfile error handling by including 0 as a recognized error code. The fix is correct and the explanation in the comments is clear. My review includes one suggestion to improve code robustness by making the set of error codes immutable.

Comment thread vllm/multimodal/media/audio.py
@AndreasKaratzas AndreasKaratzas marked this pull request as ready for review March 22, 2026 01:46
@AndreasKaratzas AndreasKaratzas added the ready ONLY add when PR is ready to merge/full CI is needed label Mar 22, 2026
@DarkLight1337 DarkLight1337 requested a review from Isotr0py March 22, 2026 05:24
Copy link
Copy Markdown
Member

@Isotr0py Isotr0py left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I also encountered this issue once during #37058, but I mistake its my network issue at that time. 😂

@Isotr0py Isotr0py merged commit 5dac719 into vllm-project:main Mar 22, 2026
47 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AMD Mar 22, 2026
@AndreasKaratzas AndreasKaratzas deleted the akaratza_fix_entrypoints_audio branch March 22, 2026 05:38
RhizoNymph pushed a commit to RhizoNymph/vllm that referenced this pull request Mar 26, 2026
…lback (vllm-project#37782)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
SouthWest7 pushed a commit to SouthWest7/vllm that referenced this pull request Mar 27, 2026
…lback (vllm-project#37782)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
khairulkabir1661 pushed a commit to khairulkabir1661/vllm that referenced this pull request Mar 27, 2026
…lback (vllm-project#37782)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
nithinvc pushed a commit to nithinvc/vllm that referenced this pull request Mar 27, 2026
…lback (vllm-project#37782)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>

Signed-off-by: Nithin Chalapathi <nithin.ch10@gmail.com>
JiantaoXu pushed a commit to JiantaoXu/vllm that referenced this pull request Mar 28, 2026
…lback (vllm-project#37782)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
mtparet pushed a commit to blackfuel-ai/vllm that referenced this pull request Apr 9, 2026
…lback (vllm-project#37782)

Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working multi-modality Related to multi-modality (#4194) ready ONLY add when PR is ready to merge/full CI is needed rocm Related to AMD ROCm

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants