Skip to content

ggml-vulkan: serialize racy vk_instance initialization#3638

Open
d-e-s-o wants to merge 1 commit intoggml-org:masterfrom
d-e-s-o:topic/fix-vk-init
Open

ggml-vulkan: serialize racy vk_instance initialization#3638
d-e-s-o wants to merge 1 commit intoggml-org:masterfrom
d-e-s-o:topic/fix-vk-init

Conversation

@d-e-s-o
Copy link

@d-e-s-o d-e-s-o commented Jan 31, 2026

When calling whisper_init_from_file_with_params_no_state() from multiple threads with the Vulkan backend enabled, segfaults abound. The problem seems to be that vk_instance initialization is not serialized properly. Introduce a mutex to fix the problem. It needs to be recursive because of the following call chain:

  ggml_vk_get_device()
  -> ggml_backend_vk_reg()
  -> ggml_vk_instance_init()

When calling whisper_init_from_file_with_params_no_state() from multiple
threads with the Vulkan backend enabled, segfaults abound. The problem
seems to be that vk_instance initialization is not serialized properly.
Introduce a mutex to fix the problem. It needs to be recursive because
of the following call chain:
  ggml_vk_get_device()
  -> ggml_backend_vk_reg()
  -> ggml_vk_instance_init()
@ggerganov
Copy link
Member

Thanks for reporting. Could you provide a minimal example of how you use libwhisper in order to trigger this race condition? Ideally a self-contained program that reproduces the segfault.

@d-e-s-o
Copy link
Author

d-e-s-o commented Feb 9, 2026

I am using it via the whisper-rs Rust bindings, so that's all I can offer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants