Description
System information
Commit hash: c8a2202 (current master)
Issue description
In trie/triedb/hashdb.Database.commit
a key is read from dirites map without locking db lock, while trie/tiredb/hashdb.Database.dereference
may modify the map concurrently resulting in concurrent map read and map write
panic.
Possible scenario affected by the issue
One scenario affected by the race is when a new block state is committed and concurrently an rpc is called (e.g. debug_traceBlockByNumber
) which executes eth.StateAtBlock
querying a state that is available in live database and then executes tracers.StateReleaseFunc
which dereferences a node.
Code pointers
-
Read access to
dirties
map:
go-ethereum/trie/triedb/hashdb/database.go
Lines 479 to 484 in c8a2202
-
Write access to
dirties
map:
go-ethereum/trie/triedb/hashdb/database.go
Line 337 in c8a2202
-
Example of place where
dereference
is called in rpc handling goroutine:
go-ethereum/eth/tracers/api.go
Lines 569 to 586 in c8a2202
go-ethereum/eth/api_backend.go
Lines 411 to 412 in c8a2202
go-ethereum/eth/state_accessor.go
Lines 211 to 214 in c8a2202
go-ethereum/eth/state_accessor.go
Lines 50 to 60 in c8a2202
- Example of place where
commit
is called in another goroutine:
go-ethereum/core/blockchain.go
Line 1457 in c8a2202
Proposed solution
Lock db lock when accessing dirties
map in hashdb.Database.commit
.