Skip to content

fix(agent): use atomic.Bool for AgentLoop.running to prevent data race#30

Merged
yinwm merged 1 commit intosipeed:mainfrom
DevEverything01:fix/atomic-running
Feb 12, 2026
Merged

fix(agent): use atomic.Bool for AgentLoop.running to prevent data race#30
yinwm merged 1 commit intosipeed:mainfrom
DevEverything01:fix/atomic-running

Conversation

@DevEverything01
Copy link
Contributor

Summary

  • Replace bare bool with sync/atomic.Bool for the AgentLoop.running field

Problem

Run() reads running in a loop on one goroutine, while Stop() writes it from another. Without synchronization this is a data race per the Go memory model.

Changes

Before After
running bool running atomic.Bool
al.running = true al.running.Store(true)
for al.running { for al.running.Load() {
al.running = false al.running.Store(false)

1 file changed, 5 insertions(+), 5 deletions(-)

Test plan

  • go build ./... passes
  • go vet ./... passes
  • go test ./... passes

Run() and Stop() access the `running` field from different goroutines
without synchronization. Replace the bare `bool` with `sync/atomic.Bool`
to eliminate the data race.
@yinwm yinwm merged commit fe59662 into sipeed:main Feb 12, 2026
@yinwm
Copy link
Collaborator

yinwm commented Feb 12, 2026

thanks for pr

@Zepan
Copy link
Contributor

Zepan commented Feb 13, 2026

Thanks for your contribution! We are forming the PicoClaw Dev Group to accelerate the evolution of the project. Any developer with more than one merged PR is invited to join.

Would you like to join the PicoClaw Dev Group? If so, please send an email to support@sipeed.com with the subject line: [Join PicoClaw Dev Group] + Your GitHub account. We will send the Discord invite link to your inbox.

emadomedher pushed a commit to emadomedher/picoclaw that referenced this pull request Feb 17, 2026
fix(agent): use atomic.Bool for AgentLoop.running to prevent data race
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.

3 participants