sassoftware / sassoftware/arke

Race in server.Consume between teardown and spawned goroutines

Open
#95 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug go
Dominant language
Go
Stars
6
Forks
2
Avg merge
2d 2h
Merged PRs (30d)
8

Description

server.Consume spawns sender and Subscribe goroutines that write to returnError and read stopForLoop through heap-escaped pointers, but Consume returns without waiting for them. The goroutines outlive Consume, racing against its writes to returnError and its deferred close+nil of stopForLoop.

Concretely:

  • multiple writers can land on returnError (the spawned goroutines plus the main path) with no synchronization;
  • stopForLoop is closed and nil'd by Consume's defer while the goroutines may still be reading it.

Consume should wait for the spawned goroutines before returning, and stopForLoop should carry the error itself so the main path remains the sole writer of returnError.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the server.Consume entry point and trace the spawned sender and Subscribe goroutines, focusing on their access to returnError and stopForLoop. Run the relevant Go tests with the race detector; done means Consume waits for those goroutines, the main path is the sole returnError writer, and teardown no longer races with goroutine reads.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, grpc
Domain
api, backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.