grammar: add test case for nullable symbol loop
Reproduce stack overflow (or OOM) with ( [x]* )* found while adding
GBNF support to ripgrep-edit.
llama-server reproducer:
curl \
-X POST \
-d '{
"messages": [{ "role": "user", "content": "write yes" }],
"grammar": "root ::= ( [x]* )*"
}' \
-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
This commit is contained in:
parent
d3dce4e0a5
commit
17d8309fe0
|
|
@ -784,6 +784,24 @@ static void test_quantifiers() {
|
|||
"0xFF 0x12 0xAB 0x00 0x00 0x00",
|
||||
}
|
||||
);
|
||||
test_grammar(
|
||||
"segfault",
|
||||
// Grammar
|
||||
R"""(
|
||||
root ::= ( [x]* )*
|
||||
)""",
|
||||
// Passing strings
|
||||
{
|
||||
"",
|
||||
"x",
|
||||
"xx"
|
||||
},
|
||||
// Failing strings
|
||||
{
|
||||
"y",
|
||||
"yy"
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
static void test_failure_missing_root() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue