Repository navigation
Conversation
Both are extern "C" and call straight into ctx->encode/ctx->decode with no handler, so anything thrown below them unwinds across a C boundary and the process aborts. A Vulkan device loss does this today, but any backend can throw. Wrap both in try/catch like the other public entry points in this file, log, and return -4.
|
Hi @bogdanr, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
|
Closing this for now - I opened two at once and the guidance is one PR at a time for a first contribution. The Vulkan fix in #27183 is the one that matters; I will reopen this after it lands. |
llama_encodeandllama_decodeareextern "C"and call straight intoctx->encode/ctx->decodewith no handler. Anything thrown below them unwinds across a C boundary, which is undefined; in practice the process aborts and the caller never gets a chance to do anything about it.This is not hypothetical - a Vulkan device loss does it today:
I've sent a separate PR fixing that particular throw in the Vulkan backend (#27183). This one is the belt-and-braces half: no exception should cross these two entry points regardless of which backend threw it, or which future one starts to.
The neighbouring public entry points in
llama-context.cppalready do exactly this -try/catch (const std::exception & err), log, return - so this just bringsllama_encodeandllama_decodein line with them.-4fits the documented "< -1 - fatal error" range forllama_decodeand "< 0 - error" forllama_encode, and doesn't collide with the existing-1/-2/-3.Kept separate from the Vulkan PR on purpose: that one is a backend bug fix, this one has a wider blast radius and you may want to weigh them apart.