Repository navigation
server: return instead of continuing after a failed mtmd chunk (release() nulls slot.task) — fixes #1489 on the pinned branch - #246
Conversation
…se release() nulls slot.task (engine ggml-org#1489) Same one-line fix as #245, cherry-picked onto 1bit/hrx-vulkan-patched -- the branch the engine actually pins. The bug site is identical on this branch (tools/server/server-context.cpp:3667-3670), so until this lands the pinned tree still dies on a failed CLIP encode. A CLIP encode failure kills llama-server with SIGSEGV three milliseconds after it has already produced the error. Reproduced with a backtrace, and the frame names the site: Thread 1 received signal SIGSEGV #0 server_context_impl::pre_decode()::{lambda(server_slot&)#5}::operator()(server_slot&) #1 server_context_impl::iterate(std::vector<server_slot>&, std::function<void(server_slot&)>) #2 server_context_impl::pre_decode() #3 server_context_impl::update_slots() The failing path is the multimodal chunk loop in pre_decode(): process_mtmd_chunk() returns non-zero, the slot's error is sent, slot.release() runs - which does both "task_prev = std::move(task)" and "task.reset()", leaving slot.task null - and then "continue" re-enters that loop, whose first statement reads slot.task->n_tokens(). Null dereference, every time. Return instead: the slot has been released, nothing is left to advance (the failed chunk was never added to the prompt or the cache), and it must not be batched in this pass. Upstream check, since the reviewer of #245 could not reach it from the fork tree: at upstream origin/master the equivalent handler does slot.release(); return; // the slot is done, skip it entirely (verified by fetching origin/master into a fork checkout and reading tools/server/server-context.cpp there; the honest caveat is that upstream has since refactored the chunk helper into free functions, so the surrounding code differs while the failure handling does not). No other site in this file releases a slot and then continues (checked on this branch). Not verified by a rebuild in this lane: this tree has no configured HRX build, and the box's only configured one is a shared build tree whose rebuild is precisely the ggml-org#1403 incident. The pre-fix crash is recorded with the full backtrace in engine ggml-org#1489; the post-fix acceptance is the issue's own - an HTTP error and a live process.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 91ea06b903cabc114c02bbdd4069cc72a796bc07.
Cherry-picked onto the branch the engine actually pins, and I checked that rather than the sentence:
$ git merge-base --is-ancestor c94b3cc97 origin/1bit/hrx-vulkan-patched -> yes
$ git show origin/…/server-context.cpp (before) … slot.release(); continue;
$ git diff origin/hrx5 pr246 (after) … slot.release(); return;
So the base is on 1bit/hrx-vulkan-patched, and the one-line change is exactly the right one for the mechanism it names: release() moves the task into task_prev and resets slot.task, so continue re-enters the chunk loop and the next slot.task->n_tokens() dereferences null — the SIGSEGV that killed llama-server 3 ms after the error line (ggml-org#1489). Upstream master returns at the equivalent handler, which is the strongest available argument for return over any local rearrangement.
Two notes, neither blocking:
returnexits the slot loop, not just this chunk loop — the comment says "the slot is done, skip it entirely", which is true for this slot but also means other slots waiting in the same pass are not served this iteration. That is upstream's behaviour and the safe side of the trade (a null deref versus a delayed slot), and it is worth knowing when reading a server log where one failed image appears to have queued others.- The #245 → #246 history is the useful part of this PR for the fleet: two reviewers caught that #245 targeted
1bit/hrx-vulkanwhile the engine pins-patched, and the retarget would have shown 10 237 commits as the diff. That is the review system doing exactly what it is for.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 91ea06b903cabc114c02bbdd4069cc72a796bc07
This is the same patch as #245 (which is now closed), so the analysis carries over — and I re-checked the two facts it rests on at this head, because a rebase is exactly where a line number can move:
release() -> reset(): task_prev = std::move(task); task.reset(); (:376-377) slot.task is null afterwards
loop top: cur_token_idx >= slot.task->n_tokens() || … (:3657) the deref on the next iteration
the fix: return; (:3672) instead of continue
So continue re-enters the chunk loop and reads a task that release() has just moved away and reset — the SIGSEGV in engine ggml-org#1489, 3 ms after the error line because the next iteration is microseconds away. return ends the slot's chunk work, which is what upstream master does at the equivalent handler.
The one thing this version says better than #245 is the sentence that makes it reviewable: "Upstream master returns at the equivalent handler." A local fix that matches upstream is one that will not silently diverge at the next rebase; without that line, the next reader has to go and check.
The state after the branch is right too, and it predates this PR rather than being changed by it: the client has already been sent failed to process image (ERROR_TYPE_SERVER), the prompt's chunk was never pushed into the cache, and slot.n_prompt_tokens_processed was not advanced — so a poisoned image fails the request cleanly instead of corrupting the slot's accounting.
Not run: the reproduction (a deliberately failing CLIP encode). The release() → null → deref chain is deterministic and needs no runtime; the command that would show it is a llama-server with a mismatched --mmproj and an image request.
Same one-line fix as #245, moved onto the branch the engine pins. #245 targeted
1bit/hrx-vulkan; the reviewers there correctly pointed out thatthe engine pins
1bit/hrx-vulkan-patchedand that retargeting would show 10 237 commits as the diff, so this is a cherry-pick onto-patchedatc94b3cc97. The bug is identical on this branch —tools/server/server-context.cpp:3667-3670— so until this lands, the pinned tree still dieson a failed CLIP encode.
Root cause (unchanged, reproduced with a backtrace)
A failed multimodal encode kills
llama-serverwith SIGSEGV three milliseconds after it has already produced the error:The handler does
send_error(...),slot.release(), thencontinue;.release()reachesreset(), which doestask_prev = std::move(task); task.reset();— soslot.taskis null — andcontinuere-enters thewhile (true)chunk loop, whose first statement iscur_token_idx >= slot.task->n_tokens(). Deterministic null dereference, independent of backend.Change
continue→return: afterrelease()nothing is left to advance (the failed chunk was never added to the prompt or the cache), and the slot mustnot be batched in this pass. No other site in this file releases a slot and then continues (checked on this branch: 17
slot.release()sites, zerofollowed by
continue).On "upstream returns here" — verifiable now
The reviewer of #245 could not reach upstream from the fork tree. It can be checked with two commands:
Upstream has since refactored the chunk helper into free functions (
process_mtmd_chunk/add_mtmd_chunk), so the surrounding code differs whilethe failure handling does not — which is the point of citing it.
Verification status
thread apply all bt, on the shipped HRX build with Qwen3-VL-2B + the F16 mmproj and one 64×64 PNG; the clientreceived
HTTP 500and the process died anyway.is precisely the Init prompts are truncated to --batch-size (max 512 tokens) ggml-org/llama.cpp#1403 incident. The binary-level proof is CI's
buildplus the issue's own acceptance: the same request must produce an HTTPerror and leave the process alive.
Fixes ggml-org#1489 (engine). Replaces #245.