Skip to content

chat : fix out_of_range crash in throw path (#20424 regression)#20777

Merged
pwilkin merged 4 commits intoggml-org:masterfrom
jpohhhh:fix-throw-out-of-range
Mar 20, 2026
Merged

chat : fix out_of_range crash in throw path (#20424 regression)#20777
pwilkin merged 4 commits intoggml-org:masterfrom
jpohhhh:fix-throw-out-of-range

Conversation

@jpohhhh
Copy link
Contributor

@jpohhhh jpohhhh commented Mar 20, 2026

#20424 introduced effective_input = generation_prompt + input, but the throw path uses input.substr(result.end) where result.end is a position within effective_input. Every thinking model with a non-empty generation_prompt crashes with std::out_of_range instead of the intended error message.

Test crashes on unpatched master, passes with fix:

cmake -B build -DLLAMA_BUILD_TESTS=ON -DLLAMA_BUILD_TOOLS=OFF
cmake --build build --target test-chat
./build/bin/test-chat

ggml-org#20424 introduced effective_input = generation_prompt + input, but the
throw path uses input.substr(result.end) where result.end is a position
within effective_input. Every thinking model with a non-empty
generation_prompt crashes with std::out_of_range instead of the intended
error message.

Test crashes on unpatched master, passes with fix:

  cmake -B build -DLLAMA_BUILD_TESTS=ON -DLLAMA_BUILD_TOOLS=OFF
  cmake --build build --target test-chat
  ./build/bin/test-chat
@github-actions github-actions bot added the testing Everything test related label Mar 20, 2026
@pwilkin pwilkin merged commit c46583b into ggml-org:master Mar 20, 2026
46 of 48 checks passed
Ethan-a2 pushed a commit to Ethan-a2/llama.cpp that referenced this pull request Mar 20, 2026
…regression) (ggml-org#20777)

* chat : fix out_of_range crash in throw path (ggml-org#20424 regression)

ggml-org#20424 introduced effective_input = generation_prompt + input, but the
throw path uses input.substr(result.end) where result.end is a position
within effective_input. Every thinking model with a non-empty
generation_prompt crashes with std::out_of_range instead of the intended
error message.

Test crashes on unpatched master, passes with fix:

  cmake -B build -DLLAMA_BUILD_TESTS=ON -DLLAMA_BUILD_TOOLS=OFF
  cmake --build build --target test-chat
  ./build/bin/test-chat

* Update test-chat.cpp

* Update test-chat.cpp

* Update test-chat.cpp

---------

Co-authored-by: Piotr Wilkin (ilintar) <piotr.wilkin@syndatis.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants