fix(task): self-termination now triggers context switch#6923
Conversation
terminate_task_internal() moved the task to the dormant queue before checking `t == q_ready_` for the context-switch decision. Since the task was already removed from the ready queue, the comparison was always false, leaving a self-terminated task running as a zombie until the next natural exit point. Capture `was_running` before the queue transition and use it for the switch decision.
There was a problem hiding this comment.
Code Review
This pull request updates the task termination logic in task.c to determine if a task was running before its status is set to dormant, using this state to trigger a context switch. Additionally, a test case has been added in task.rb to verify that self-termination correctly switches context to the next task. There are no review comments, so no feedback is provided.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Thanks for the careful write-up in #6922, this was a clean catch. The Merged into master as 7156895 (I pushed the reviewed commit directly together with #6924, since the two touched the same tail of test/task.rb). The regression test is in too. |
terminate_task_internal() moved the task to the dormant queue before checking
t == q_ready_for the context-switch decision. Since the task was already removed from the ready queue, the comparison was always false, leaving a self-terminated task running as a zombie until the next natural exit point.Capture
was_runningbefore the queue transition and use it for the switch decision.Part of #6922 (see issue for a related sleep()-suspends-wrong-task bug, filed as a separate PR).