Skip to content

record: non atomic access of atomic field #1692

@nicktrav

Description

@nicktrav

This was noticed in cockroachdb/cockroach#81511.

This field is declared to be atomic:

// buf[:written] has already been filled with fragments. Updated atomically.
written int32

Yet we read from it non-atomically here:

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.

Metadata

Metadata

Assignees

Labels

C-bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions