From e06e1355aad5fe848110100c1754d311e144bc48 Mon Sep 17 00:00:00 2001 From: Jonathan Oppenheimer Date: Tue, 6 Jan 2026 16:51:16 -0500 Subject: [PATCH] fix: fix multiple abort attempts --- core/state/snapshot/disklayer.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/core/state/snapshot/disklayer.go b/core/state/snapshot/disklayer.go index a9b3d703ff..f4866c1ba3 100644 --- a/core/state/snapshot/disklayer.go +++ b/core/state/snapshot/disklayer.go @@ -193,9 +193,21 @@ func (dl *diskLayer) stopGeneration() { // Check if generation goroutine is running by checking if genAbort channel exists. // Note: genMarker can be nil even when the generator is still running (waiting // for abort signal after completing generation), so we check genAbort instead. - if dl.genAbort != nil { - abort := make(chan *generatorStats) - dl.genAbort <- abort - <-abort + // + // Use write lock to ensure only one stop can proceed at a time and to safely + // clear genAbort after the generator exits. + dl.lock.Lock() + defer dl.lock.Unlock() + + if dl.genAbort == nil { + return } + + abort := make(chan *generatorStats) + dl.genAbort <- abort + <-abort + + // Clear genAbort to prevent subsequent calls from trying to send to a channel + // that no longer has a listener, which would block forever. + dl.genAbort = nil }