-
Notifications
You must be signed in to change notification settings - Fork 556
record: non atomic access of atomic field #1692
Copy link
Copy link
Closed
Labels
C-bugSomething isn't workingSomething isn't working
Description
This was noticed in cockroachdb/cockroach#81511.
This field is declared to be atomic:
Lines 25 to 26 in 9bd4314
| // buf[:written] has already been filled with fragments. Updated atomically. | |
| written int32 |
Yet we read from it non-atomically here:
Line 678 in 9bd4314
| i := b.written |
A trivial fix would be to update the read-site to read atomically.
While we're in here, we should audit the read/write call-sites to make sure we're honoring the atomic call-site.
It may even be worth some sugar in the struct to highlight the fact that the field is atomic (i.e. block.atomic.writer). I believe I've seen this patten adopted elsewhere.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugSomething isn't workingSomething isn't working