Skip to content

speculative-simple, speculative: fix init error handling causing crash - #31996

Open
JamieBordoni wants to merge 1 commit into
ggml-org:masterfrom
JamieBordoni:crash-when-context-init-fails
Open

JamieBordoni wants to merge 1 commit into
ggml-org:masterfrom
JamieBordoni:crash-when-context-init-fails

Conversation

@JamieBordoni

Copy link
Copy Markdown
Contributor

Overview

Fixed issue where running speculative examples when the model or context fails to initialize would print an error but still crash with exit code 139. Process now exits cleanly with error code 1.

Additional information

Reproducer:

llama-speculative -hf bartowski/SmolLM2-135M-Instruct-GGUF:Q8_0 -hfd bartowski/SmolLM2-135M-Instruct-GGUF:Q8_0 -c 100000000 -p "hello" -n 8

Crashes with:

E llama_init_from_model: failed to initialize the context: failed to allocate buffer for kv cache
E cmn  common_init_: failed to create context with model '...'
Segmentation fault (core dumped)
exit code: 139

After:

E cmn  common_init_: failed to create context with model '...'
E main : failed to init target
exit code: 1

When model initialization function returns null llama speculative would carry on using the null pointers without first checking if model and ctx were null causing program to crash.

Also tested with llama-speculative-simple with the same large -c reproducer and llama-speculative with -md pointing to a file which doesn't exist. Both segfaulted before now exits with error 1. Normal runs still generate text with exit 0.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES, AI helped find the bug and understand the code, I wrote the fix and tested it.

@JamieBordoni
JamieBordoni requested a review from a team as a code owner November 10, 2026 03:24
@JamieBordoni

JamieBordoni commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Closed as new contributors are limited to 1 pr and i think #32000 is more important.

@JamieBordoni

JamieBordoni commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor Author

reopened now that #32000 has merged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant