Skip to content

flaky test: kernel::tests::test_cancel_interrupts_for_loop races cancellation against loop completion under load #149

Description

@tobert

Discovered incidentally while hammering cargo test --all --features subprocess -- --test-threads=64 under heavy host load (load average ~50-130 on a 32-core box, from concurrent unrelated builds) trying to reproduce #135.

kernel::tests::test_cancel_interrupts_for_loop (unit test in crates/kaish-kernel/src/kernel.rs) asserts that a cancelled for loop exits with code 130:

thread 'kernel::tests::test_cancel_interrupts_for_loop' (963523) panicked at crates/kaish-kernel/src/kernel.rs:7514:9:
assertion `left == right` failed: cancelled execution should exit with code 130
  left: 0
 right: 130

left: 0 means the loop ran to completion (exit 0) instead of being interrupted (130) — under heavy CPU contention the cancellation signal/check apparently doesn't land before the loop body finishes, so the race between "issue cancel" and "loop completes on its own" tips the wrong way when scheduling is starved. Not otherwise investigated further (didn't look at the test's exact timing setup, e.g. whether it races a fixed sleep against a spawned cancel) — this was collateral evidence from #135's reproduction attempt, not the focus of that investigation. Worth a look at whatever timing assumption underlies the test to give it real margin under load, similar in spirit to #148.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions