← Lab
piecebounds
confirmedupstream bugC++ · llama.cppInference & servingJuly 13, 2026
the question
Does the public llama_token_to_piece crash on an out-of-range token id?
what came out
Once a vocab loads, every llama_token_to_piece call hits an unchecked cache.at(token); an id below 0 or at or above n_tokens throws std::out_of_range across the extern C boundary and aborts a handler-less caller with SIGABRT. The crash boundary is exactly [0, n_tokens) and the function's own guard is dead code.
method & receipts
- Result: confirmed
- Pre-registered — the prediction was written down and committed before the run.
- Reproducible — one script re-runs the whole thing from scratch.
- Tested — a correctness/benchmark suite ships alongside the code.
→ read the code and re-run it
github.com/v-code01/piecebounds