fix(node): correct init error paths (double free / double thread_pool deinit)#877
Merged
Conversation
- BeamNode.init: drop duplicate errdefer on *BeamChain; on BeamChain.init failure destroy the allocation only; keep a single errdefer for deinit+destroy after success. - cli Node.init: xmss.setupVerifier errors must not call thread_pool.deinit manually — errdefer already runs it (was double deinit).
Contributor
|
Reviewed PR #877. No blocking issues found. What I checked:
Validation:
Minor non-blocking note: the new comment says the two errdefers would double-destroy “if init failed after |
noopur23
previously approved these changes
May 13, 2026
GitHub macos-latest often ran zeam-stress with attn queue_full=0 while the block queue saturated, tripping the harness FATAL. Raise ZEAM_STRESS_SAT_ATTN_PRODUCERS for the zig build test step only, extend the quick window slightly, and widen the stall watchdog.
anshalshukla
previously approved these changes
May 13, 2026
Homebrew cargo can precede rustup's shim and rejects +nightly.
rustup-run-nightly broke rustc resolution; prepend ~/.cargo/bin on macOS.
GrapeBaBa
approved these changes
May 14, 2026
noopur23
approved these changes
May 14, 2026
This was referenced May 14, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BeamNode.init(pkgs/node/src/node.zig): Removed the overlappingerrdefer allocator.destroy(chain)that ran after theerrdefer { chain.deinit(); allocator.destroy(chain); }on any error afterBeamChain.initsucceeded. Unwind then calleddestroyon the same pointer twice → DebugAllocator double free (seen when later init steps fail, e.g. metrics bindAddressInUse/ServerStartupFailed).Node.init(pkgs/cli/src/node.zig): Onxmss.setupVerifier()failure, dropped the extrathread_pool.deinit()—errdefer self.thread_pool.deinit()already runs, so the manual call was a double deinit.Context
Operators hit
error.AddressInUseon the metrics port;startMetricsServerreturnsServerStartupFailedandNode.initunwinds. The duplicate*BeamChainteardown amplified that into allocator corruption (double free + bogus leak reports).Testing
zig build(full default pipeline) — succeeded locally.