Open
Description
This code checks that snapshot == null
before taking a lock, but never checks it again:
I think this sequence of events can result in multiple calls to CreateSnapshot()
:
- Thread 1 calls
GetSnapshot()
and seelocalSnapshot = snapshot
&&localSnapshot == null
- Thread 2 calls
GetSnapshot()
and seelocalSnapshot = snapshot
&&localSnapshot == null
- Thread 1 enters the lock block, and runs CreateSnapshot, and updates
snapshot
- Thread 2 enters the lock block, runs CreateSnapshot again, and updates
snapshot
again.