Skip to content

fix(simpleradio): use atomic.Bool for secureCoalitionRadios#672

Merged
dharmab merged 1 commit into
dharmab:mainfrom
SAY-5:fix/secure-coalition-radios-race-661
May 7, 2026
Merged

fix(simpleradio): use atomic.Bool for secureCoalitionRadios#672
dharmab merged 1 commit into
dharmab:mainfrom
SAY-5:fix/secure-coalition-radios-race-661

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented Apr 23, 2026

Fixes #661.

Problem

secureCoalitionRadios was a plain bool written from the TCP receiver goroutine in updateServerSettings (pkg/simpleradio/message.go:77-91) and read from the UDP receiver goroutine (pkg/simpleradio/receive.go:107) with no synchronization. The Go race detector flagged it, and an unlucky interleaving could let a voice packet skip the coalition filter while the flag was flipping.

Fix

Switch the field to sync/atomic.Bool and route the write/read through Store/Load. The one-shot "enabling secure coalition radios" transition log still fires only when the flag actually flips, via a Load() check before Store(true).

Test

gofmt clean. go test -race locally fails to link because the opus/opusfile system packages aren't installed on my machine, but the race was surfaced in CI on the linked issue and this is the minimal correctness fix.

@dharmab
Copy link
Copy Markdown
Owner

dharmab commented May 5, 2026

Thank you for the patch! LGTM after the checks pass.

The TCP receiver goroutine writes c.secureCoalitionRadios from
updateServerSettings while the UDP receiver goroutine reads it from
the voice-packet handling path, with no synchronization — a data race
the Go race detector flags and an unlucky interleaving could let a
voice packet skip the coalition filter while the flag is flipping.

Switch the field to sync/atomic.Bool and route the write/read through
Store/Load. The tri-state log message ('enabling secure coalition
radios') still fires only on transitions, via a Load() check before
Store(true).

Refs dharmab/skyeye issue 661.

Signed-off-by: SAY-5 <say.apm35@gmail.com>
@dharmab dharmab force-pushed the fix/secure-coalition-radios-race-661 branch from efa7194 to 1c2f5f8 Compare May 5, 2026 05:00
@dharmab dharmab enabled auto-merge (squash) May 5, 2026 22:31
@dharmab
Copy link
Copy Markdown
Owner

dharmab commented May 7, 2026

It turns out CodeQL scanning just gets stuck sometimes for no reason https://github.com/orgs/community/discussions/159026

I've never actually taken any actionable insight from the CodeQL scanner anyway, so I'm just going to disable it.

@dharmab dharmab disabled auto-merge May 7, 2026 05:16
@dharmab dharmab merged commit d2c92f1 into dharmab:main May 7, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data race on secureCoalitionRadios bool

2 participants