From c537f77a4dac9f31164e29f9b5cbda7fe6284ed1 Mon Sep 17 00:00:00 2001 From: Andrea Arcangeli Date: Fri, 2 Jan 2026 17:42:31 +0100 Subject: [PATCH] grammar: add test case for hang in repetition grammar processing This commit adds a new test case to the grammar integration tests that specifically targets a hang scenario in the repetition grammar parser found while adding GBNF support to ripgrep-edit. llama-server reproducer: curl \ -X POST \ -d '{ "messages": [{ "role": "user", "content": "write yes" }], "grammar": "root ::= (([^x]*){0,99}){0,99}" }' \ -H "Content-Type: application/json" \ http://localhost:8811/v1/chat/completions Not security related according to https://github.com/ggml-org/llama.cpp/security#untrusted-environments-or-networks --- tests/test-grammar-integration.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test-grammar-integration.cpp b/tests/test-grammar-integration.cpp index 84a680c670..74bf41eb7e 100644 --- a/tests/test-grammar-integration.cpp +++ b/tests/test-grammar-integration.cpp @@ -802,6 +802,19 @@ static void test_quantifiers() { "yy" } ); + test_grammar( + "hang", + // Grammar + R"""( + root ::= (((((([^x]*){0,99}){0,99}){0,99}){0,99}){0,99}){0,99} + )""", + // Passing strings + { + }, + // Failing strings + { + } + ); } static void test_failure_missing_root() {