From f8f2e469250289cba9afdc7c1f9a07b77497d3f3 Mon Sep 17 00:00:00 2001 From: Wagner Bruna Date: Tue, 16 Sep 2025 19:56:48 -0300 Subject: [PATCH] fix: avoid crash on multithreaded model conversion --- model.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/model.cpp b/model.cpp index 168b675d..10ec81f1 100644 --- a/model.cpp +++ b/model.cpp @@ -2427,7 +2427,12 @@ bool ModelLoader::save_to_gguf_file(const std::string& file_path, ggml_type type auto tensor_type_rules = parse_tensor_type_rules(tensor_type_rules_str); + std::mutex mux_conversion; + auto on_new_tensor_cb = [&](const TensorStorage& tensor_storage, ggml_tensor** dst_tensor) -> bool { + + std::lock_guard lock(mux_conversion); + const std::string& name = tensor_storage.name; ggml_type tensor_type = tensor_storage.type; ggml_type dst_type = type;