Skip to content

pool: the lock-waiter test helper reads the whole goroutine dump - #704

Merged
CMGS merged 1 commit into
mainfrom
test/lock-waiter-stack
Dec 3, 2026
Merged

CMGS merged 1 commit into
mainfrom
test/lock-waiter-stack

Conversation

@CMGS

@CMGS CMGS commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Tests only.

go test -race -count=5 ./pool/ fails on main: three tests time out in waitLockWaiter from the second iteration on (-count=1, which CI and the gate run, passes). The helper reads runtime.Stack(buf, true) into a fixed 1 MiB buffer and looks for the goroutine that waits on a lock. The package's tests leave about 475 goroutines behind per iteration, so from the second iteration the dump no longer fits and the goroutine it looks for is cut off.

Measured on the old helper, full package, -race -count=5: at every failing wait every poll filled the buffer (n == len(buf), for example 274 of 274 polls); the whole dump was 1.55 MB at about 1270 goroutines in iteration 2, 2.13 MB in iteration 3, 2.71 MB in iteration 4; in one case the waited frame sat at offset 1592084.

The helper now grows its buffer until the dump fits (+4 lines). With it the full package at -race -count=5 passes on macOS (256 s) and in a Linux arm64 container (188 s).

The goroutines that pile up are per-claim doors and one loop per outbound.Host (boot doors, proxy servers, tun and SOCKS loops), plus a test client's idle connections and the claim store's retry loop in tests that keep the store broken. They belong to claims the tests still hold when they end: the test manager has no teardown, and each test builds its own host. In the daemon a door ends when its claim is disarmed and the host lives as long as the process, so this is test residue, not a leak in production code; no teardown is added for it here.

sbx-gate.sh ends GATES PASS.

At -count>1 the package keeps over a thousand goroutines alive, the dump outgrows the fixed 1 MiB buffer, and the waited-for goroutine is cut off.
@CMGS
CMGS merged commit d603682 into main Dec 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant