test(runtime): wait for the IO thread before counting operations #339
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/338-io-cancel-leak-flake"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #338
test_io_a_cancelled_wait_releases_its_registrationreadtorb_network_operations_alive(): 2, expected 1atio_test.c:301in the push run onmainatd679af0(tier B linux-x64); the "2 blocks leaked" were the message list and task the early return left behind.Cause.
torb_io_completewakes the task (torb_task_io_done) before it drops the kernel's reference (torb_io_operation_release). The accept and connect ofconnected_paircan therefore answer while the IO thread still holds their operations for a moment, and the test counted right then. No runtime leak: the count reaches the expected value once the IO thread runs on, and reordering the two steps in the runtime would let a cancelled task's operation be freed before the wake touches it.Fix (test only).
operations_alive_settled(expected)waits up to a second while more thanexpectedoperations are alive (the same bound the test andtorb_io_stopalready used after the cancel) and answers the count. Used for the count with the receive waiting (1) and after the cancel (0). The other counts inio_test.cfollowtorb_scheduler_finish(), which already waits for the IO thread; the child-read count at the end has no earlier operation.No seed impact, runtime C tests only.
Review of
787f63f(test-only, runtime/tests/io_test.c):expectedoperations are alive, bounded to 1 s (same bound as the removed loop), then returns the real count, so a genuine leak still fails the check. The cause (wake before release intorb_io_complete) matches the described race; leaving the runtime order alone is right.Non-blocking: none.