Skip to content

Conversation

@Fibonacci747
Copy link
Contributor

Fixed a closure capture bug where the goroutine inside generateTrieRoot captured the loop variable holding a decoded StateAccount, which was then reassigned in subsequent iterations. Because Go closures capture variables by reference, concurrent goroutines could observe the mutated variable and read CodeHash and Root from the wrong account, producing spurious “invalid subroot” errors and introducing a data race. The fix renames the local variable to acc for clarity and, more importantly, computes fixed values for hash, codeHash, and wantRoot before spawning the goroutine and passes them as parameters, ensuring each goroutine operates on the correct account snapshot. The same correction is applied in both triedb/pathdb/verifier.go and core/state/snapshot/conversion.go to maintain consistent and safe behavior across code paths that rebuild or verify trie state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants