Closed jpaskhay closed 4 years ago
Thanks for reporting this.
In the panic function I specifically left out the acquisition of locks since I assumed when panic is called then we have no guarantees about the state of the application and don't want a condition where we deadlock if a dead procedure has the lock.
Looking back at the code, I think this can only happen when the caller has acquired the lock to either the buffer list or the coffer and panics instead of returning. Also we should probably acquire the coffer lock so that we don't have a condition where panic is called during a re-key operation.
Going to attempt to write a unit test to trigger this race.
Pushed a patch in #127, would welcome your thoughts on it. It should fix the race condition above.
Pushed a patch in #127, would welcome your thoughts on it. It should fix the race condition above.
Cool. Should be able to circle back in the next day or so.
Describe the bug Running into a transient data race in our benchmark tests where the
bufferList
is being written to while another goroutine tries to read it in thePanic
function. Looking at the code, thePanic
function is the only read performed on thebufferList.list
without a read lock.To Reproduce It seems to be a timing issue in our benchmark, so it's tricky to reliably reproduce. In our specific failure, It seems to occur as a result of an mlock request failing (resulting in
Panic
being called) at the same time as a write tobufferList
from aBuffer.Destroy
call. Here are the relevant snippets of the data race stacks:Expected behaviour No data race warning. This may be relatively minor since even after a fix it would still panic, but could still be preferred to avoid the data race.
Screenshots N/A
System (please complete the following information):
Debian GNU/Linux 10 (buster)
(using thegolang:1.12
Docker image in our builds)Additional context Will submit PR for possible fix.