From b932cd742853eeb6a8788a80188f19f0acebaa1c Mon Sep 17 00:00:00 2001 From: Jared Van Bortel Date: Thu, 30 Nov 2023 16:50:20 -0500 Subject: [PATCH] vulkan : correctly fix use-after-free in ggml_vk_current_device The previous attempt actually broke GPU inference with the 'main' example, which was previously working. deviceName is a vk::ArrayWrapper1D. Be careful when we convert it to a std::string, so we don't get null bytes at the end. --- ggml-kompute.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ggml-kompute.cpp b/ggml-kompute.cpp index fa7baf7e8..1704bc9da 100644 --- a/ggml-kompute.cpp +++ b/ggml-kompute.cpp @@ -340,8 +340,9 @@ ggml_vk_device ggml_vk_current_device() { if (!komputeManager()->hasDevice()) return ggml_vk_device(); - auto devices = ggml_vk_available_devices_internal(0); - ggml_vk_filterByName(devices, komputeManager()->physicalDevice()->getProperties().deviceName); + auto devices = ggml_vk_available_devices(0); + ggml_vk_filterByName(devices, komputeManager()->physicalDevice()->getProperties().deviceName.data()); + GGML_ASSERT(!devices.empty()); return devices.front(); }