From 3b257f88674b005144f20e7bfd8291046018c4fa Mon Sep 17 00:00:00 2001 From: Francis Couture-Harpin Date: Fri, 1 Mar 2024 10:32:38 -0500 Subject: [PATCH] llama : fix segfault from unknown model arch name --- llama.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/llama.cpp b/llama.cpp index b1db5b179..042fa36d1 100644 --- a/llama.cpp +++ b/llama.cpp @@ -809,6 +809,16 @@ static std::map> LLM_TENSOR_NAMES = static llm_arch llm_arch_from_string(const std::string & name) { for (const auto & kv : LLM_ARCH_NAMES) { // NOLINT + if (kv.second == nullptr) { + // LLM_ARCH_UNKNOWN does not have a name, + // but is somehow still in the LLM_ARCH_NAMES map. + if (kv.first == LLM_ARCH_UNKNOWN) { + // skip string comparison + continue; + } + // known architectures should always have a name + GGML_ASSERT(false && "missing architecture in LLM_ARCH_NAMES"); + } if (kv.second == name) { return kv.first; }