Skip to content

server : fix crash when seq_rm fails for hybrid/recurrent models - #18391

Merged
ngxson merged 2 commits into
ggml-org:masterfrom
o7si:issue-18235
Dec 26, 2025
Merged

ngxson merged 2 commits into
ggml-org:masterfrom
o7si:issue-18235

Conversation

@o7si

@o7si o7si commented Dec 26, 2025 •

Copy link
Copy Markdown
Contributor

When the model is a hybrid/recurrent model, llama_memory_seq_rm may fail. In this case, the slot's status is not SLOT_STATE_IDLE.

if (!llama_memory_seq_rm(llama_get_memory(ctx), slot.id, p0, -1)) {
SLT_WRN(slot, "failed to truncate tokens with position >= %d - clearing the memory\n", p0);
clear_slot(slot);
// there is no common part left
slot.n_prompt_tokens_cache = 0;
}

So calling clear_slot will trigger GGML_ASSERT, causing the program to crash.

void clear_slot(server_slot & slot) const {
GGML_ASSERT(!slot.is_processing());
SLT_WRN(slot, "clearing slot with %zu tokens\n", slot.prompt.tokens.size());
llama_memory_seq_rm(llama_get_memory(ctx), slot.id, -1, -1);
slot.prompt.tokens.clear();
}

Related issue:

Comment thread tools/server/server-context.cpp Outdated
Comment on lines +2223 to +2224
llama_memory_seq_rm(llama_get_memory(ctx), slot.id, -1, -1);
slot.prompt.tokens.clear();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of duplicating this code, simply add a second argument in clear_slot:

clear_slot(server_slot & slot, bool allow_processing)

@o7si o7si Dec 26, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should allow_processing have a default value? I think it should default to false to maintain the existing behavior and safety check for most cases:

void clear_slot(server_slot & slot, bool allow_processing = false);

@ngxson
ngxson merged commit 4893cc0 into ggml-org:master Dec 26, 2025
70 of 71 checks passed
blime4 referenced this pull request in blime4/llama.cpp Feb 5, 2026
…391)

* server : fix crash when seq_rm fails for hybrid/recurrent models

* server : add allow_processing param to clear_slot
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
…l-org#18391)

* server : fix crash when seq_rm fails for hybrid/recurrent models

* server : add allow_processing param to clear_slot
my-other-github-account pushed a commit to my-other-github-account/llama.cpp that referenced this pull request May 15, 2026
…l-org#18391)

* server : fix crash when seq_rm fails for hybrid/recurrent models

* server : add allow_processing param to clear_slot
fukuro-kun pushed a commit to fukuro-kun/fukuro-llama-cpp-turboquant that referenced this pull request Jul 5, 2026
…l-org#18391)

* server : fix crash when seq_rm fails for hybrid/recurrent models

* server : add allow_processing param to clear_slot
MrLordCat referenced this pull request in MrLordCat/llama.cpp-rdna-lab Jul 16, 2026
…391)

* server : fix crash when seq_rm fails for hybrid/recurrent models

* server : add allow_processing param to clear_slot
zommiommy pushed a commit to zommiommy/llama.cpp that referenced this pull request Aug 18, 2026
…l-org#18391)

* server : fix crash when seq_rm fails for hybrid/recurrent models

* server : add allow_processing param to clear_slot
frostyautumnleaf pushed a commit to frostyautumnleaf/llama.cpp that referenced this pull request Oct 5, 2026
…l-org#18391)

* server : fix crash when seq_rm fails for hybrid/recurrent models

* server : add allow_processing param to clear_slot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants