Node.Stop() stalls ~80 s on an in-flight performance-certificate benchmark (RunBenchmark takes no ctx)
Report
[Minor] Node.Stop() stalls ~80 s on an in-flight performance-certificate benchmark (RunBenchmark takes no ctx)
Area: node-api / node lifecycle
Repo pin: xeprotocol/xe @ 89a542e (HEAD, verified 2026-11-14)
Suggested tier: Minor (CVSS 4.0 — local only, no remote trigger; a bounded shutdown delay, no crash, no leak, no state corruption, no funds)
Related public issue: xeprotocol/xe#561 (same ground, filed by another researcher; this report is an independent reproduction with our own Go test and our own measurements)
Summary
Node.Stop() waits out a running performance-certificate benchmark whenever a certificate attempt is in flight: an operator who stops the node during a cert attempt waits ~80 s with no response (no timeout, no interrupt). Measured at HEAD: benchmark wall 83.12 s, Stop latency 78.18 s (Stop issued 1 s into a live maintainCertificate attempt). The stall is bounded to one attempt — after it fails/completes, the loop re-checks ctx and returns — but the benchmark runs at node start (no cert yet) and at each renewal, so the window recurs on every cert cycle.
Root cause
A ~65–85 s CPU-bound, non-cancellable unit of work sits inside a wg-tracked goroutine whose only ctx checks are between attempts:
perf/benchmark.go:15,17—PoWPuzzles = 1024, 19-bit puzzles;:114RunBenchmark(seed, puzzles)takes no ctx and solves the puzzles sequentially.node/perf.go:58—generatePerformanceCertificatecallsperf.RunBenchmark(seed, perf.PoWPuzzles).node/perf.go:201—certGenerationLoopchecks ctx only between attempts (if ctx.Err() != nil { return false }before eachattempt()call); nothing checks ctx mid-attempt.node/perf.go:158—maintainCertificateruns the loop;node/node.go:557spawns it as a wg-tracked goroutine.node/node.go:1301-1308—Stop()callsn.cancel()and thenn.wg.Wait()at:1303with no timeout. The cancelled ctx cannot interrupt the benchmark, soStop()waits for the puzzles to finish.
Reproduction (our own Go test, node/zz_r56_m4_stopstall_b56_test.go, NO -race)
Two parts, both against the real code at HEAD, 2026-11-14:
- (A) The blocking unit itself:
perf.RunBenchmark(seed, perf.PoWPuzzles)— wall 83.12 s (result.Elapsed 83.118 s, score 0.0120). (Slower than the ~64–68 s seen on a quieter VM — same 1024-puzzle workload, same code path; run-to-run CPU variance on a shared VM.) - (B) Stop latency: a real node built by
New();maintainCertificatespawned exactly as production does (wg-tracked goroutine,node/node.go:557shape) with an attempt whose blocking unit is the realRunBenchmark(1024);Stop()issued 1 s into the live attempt (gated on an atomic "attempt started" flag, so the timing is deterministic). Stop latency: 78.18 s — Stop waited out the remainder of the in-flight benchmark.
The test asserts the stall (Stop latency > 30 s) rather than an exact figure, since the wall time is CPU-dependent; the mechanism (no ctx in the benchmark, no timeout in Stop()) is what the numbers demonstrate. Total test time ~162 s, no -race (race-detector overhead on this CPU-bound code is ~10–15×, making a -race run infeasible).
Impact / worst case
- An operator stopping the node during a cert attempt (SIGTERM during an upgrade or restart) sees an unresponsive shutdown for the remainder of the attempt (~65–85 s from the operator's point of view). The window recurs at node start and at each renewal, so an operator stopping the node has a realistic chance of hitting it.
- Bounded: after the in-flight attempt fails/completes, the loop re-checks ctx and returns, so
Stop()waits at most ONE attempt, not the whole retry chain. No remote trigger, no crash, no leak, no state corruption, no funds: a bounded shutdown delay. Hence Minor.
Duplicate check (re-verified at filing time, 2026-11-14 ~12:52–13:0x UTC)
- Board search
q=RunBenchmark→ XE-4975, XE-11975 only. XE-4975 (new High — provider forges its benchmark score becausework_proof/cpu_hashare never recomputed,VerifyWorkhas zero callers) is a trust defect about certificate verification, not shutdown latency; read in full. XE-11975 is a correction addendum to a cert price-multiplier ticket. Neither mentionsStop()or shutdown. q=maintainCertificate→ 0 hits.q="Node.Stop"→ XE-0041, XE-0920 only. XE-0041 (accepted Medium — SIGTERM-during-sync hang, sync ctx fromBackground()) and XE-0920 (triaging Medium — queued VM provision blocks shutdown, Limatime.After) are different functions with different blocking work; both read in full.- No board ticket names a benchmark-induced
Stop()stall.q=aurorabelle788→ 1 hit, XE-12805 (our own earlier filing) — the #561 author has not filed on the board. No new public filings since XE-12805 (XE-12806–XE-12825 all 404); xe HEAD still89a542e, pull-refs still 186, max PR #556 — no fix PR.
Remediation suggestion
Make the benchmark interruptible (pass a ctx into RunBenchmark / solvePuzzle and check it between puzzles), or bound the wait in Stop() (wait on the WaitGroup with a timeout, then proceed to close the host/store and let the benchmark goroutine finish in the background), or both. Checking ctx between puzzles keeps the per-puzzle work intact while capping the shutdown delay at one puzzle (~65 ms) instead of one attempt (~80 s).
Thread
Thanks. This is the same finding as https://bounty.xe.network/XE-13399, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-12837 and says what differs; it is read like any other.