Skip to content

fix: avoid setting db.cleans to nil on Close (ethereum#29309) - #118

Merged
hmlee-wm merged 1 commit into
devfrom
fix/hashdb-avoid-nil-cleans-on-close
Aug 10, 2026
Merged

hmlee-wm merged 1 commit into
devfrom
fix/hashdb-avoid-nil-cleans-on-close

Conversation

@hmlee-wm

@hmlee-wm hmlee-wm commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

Remove the db.cleans = nil assignment in Close() to prevent a potential data race with concurrent node() or commit() calls that access db.cleans without a lock.

Upstream References

PR Description
#29309 triedb/hashdb: Avoid setting db.cleans on Close

Problem

db.cleans is accessed without a lock in node() (L189, L214) and commit() (L532), while Close() sets it to nil also without a lock. A concurrent goroutine that passes the db.cleans != nil check and then calls db.cleans.Get/Set after Close() nullifies the pointer will panic.

Changes

  • triedb/hashdb/database.go: Remove db.cleans = nil in Close().
  • db.cleans.Reset() already clears the cache contents; the cleans field is collected by GC along with its owner db, so the nil assignment serves no purpose.
  • No behavior change for normal operation.

(cherry picked from commit f46fe62c5d1d25ce0e9869ecbaf0e5722d2bc2f5)
@hmlee-wm hmlee-wm self-assigned this Aug 5, 2026
@hmlee-wm hmlee-wm added the bug Something isn't working label Aug 5, 2026

@eomti-wm eomti-wm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@colinkim colinkim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hmlee-wm
hmlee-wm merged commit 73cac95 into dev Aug 10, 2026
3 checks passed
@hmlee-wm
hmlee-wm deleted the fix/hashdb-avoid-nil-cleans-on-close branch August 11, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants