Skip to content

Guard shared gob encoder with a mutex - #22

Merged
mattn merged 1 commit into
masterfrom
fix-encoder-race
Jul 10, 2026
Merged

Guard shared gob encoder with a mutex#22
mattn merged 1 commit into
masterfrom
fix-encoder-race

Conversation

@mattn

@mattn mattn commented Jul 10, 2026

Copy link
Copy Markdown
Owner

The stdout and stderr writer goroutines and the main goroutine all called Encode on the same gob.Encoder concurrently (both in the client and the server). gob.Encoder is not safe for concurrent use, so this races and can interleave/corrupt the gob stream.

Wrap the encoder in a small mutex-protected type used by all writers.

@mattn
mattn merged commit 1d3f916 into master Jul 10, 2026
2 checks passed
@mattn
mattn deleted the fix-encoder-race branch July 10, 2026 08:07
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.

1 participant