llama.cpp b11608 修复 server 特殊 token 转义导致的栈溢出崩溃
原标题:b11608
AI 摘要
llama.cpp 发布 b11608 版本,修复了 server 组件中特殊 token 转义的安全问题。此前 d1-omni 和 kev 提示词使用 std::regex_replace 转义请求文本中的 "<|name|>",libstdc++ 会逐字符递归,当输入 "<|" 加 30000 个字母时会撑爆 HTTP 线程栈,导致 llama-server 因 SIGSEGV 崩溃。新版本改用 server_decision_escape_special_tokens() 以循环方式实现相同转义,并新增测试与正则结果逐串比对。
正文节选
<details open> server : escape the special tokens without std::regex (#30243) The d1-omni and kev prompts escape "<|name|>" in the request text with std::regex_replace. libstdc++ recurses for each char of the name, so a state of "<|" and 30000 letters overflows the stack of the HTTP thread and llama-server dies with SIGSEGV. server_decision_escape_special_tokens() writes the same text with a loop. test-server-component compares it with the regex on every string of up to 6 chars of "<|>a-". <