AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 42 Bitcoin

threadpool: guard against Start-Stop race

Public commit record

What the developer wrote

Authored by furszy

68/100 · Adequate
threadpool: guard against Start-Stop race

Stop() has two windows where Start() could cause troubles:

1) m_workers is temporarily empty while workers are being joined,
this creates a window where Start() could slip through and reset
m_interrupt to false, preventing the old workers from exiting and
causing a deadlock.

2) Start() could be called after workers are joined but before the
empty() sanity check on m_work_queue, causing a crash.

Fix both races by keeping m_interrupt set for the entire duration
of Stop(), so any concurrent Start() call is rejected until all
workers have exited.

Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This patch fixes a timing bug in Bitcoin Core's internal worker-thread pool. If someone started the thread pool while it was still stopping, the program could freeze (deadlock) or crash. The fix keeps the pool marked as 'stopping' until every worker thread has fully exited, so a new start request is rejected during that window.

Recommended action

Review and merge. The patch is small, targeted, and the commit message clearly explains the race being fixed. No additional action is required unless downstream users rely on being able to call Start() during Stop(), which the patch intentionally prohibits.

Security signals we found

01

Race condition between Start() and Stop() in thread pool lifecycle

02

Potential deadlock when m_interrupt is reset while workers are being joined

03

Potential crash from Start() before m_work_queue empty sanity check

04

Fix uses existing m_interrupt flag to reject concurrent Start() during Stop()

Risk score

Why this scored 42/100

Our methodology →
Potential impact 12/30
Exploitability 5/25
Stealth signal 8/15
Affected reach 6/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.