Repository navigation
Fix sst tunnel crashing with concurrent map writes under load - #7017
Open
portlandhodl wants to merge 1 commit into
Open
portlandhodl wants to merge 1 commit into
portlandhodl wants to merge 1 commit into
Conversation
The tunnel proxy logs each connection with ui.GetColor(addr).Bold(true) from a separate goroutine per SOCKS connection. GetColor returned the global Colors entry by value, but lipgloss (v0.9.1) styles share their rules map across value copies, so Bold(true) wrote into the shared map. When a client opened several connections at once (e.g. a Postgres pool) the process died with "fatal error: concurrent map writes". Return a deep copy from GetColor so callers can chain setters safely. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
sst tunneldies when a client opens several connections at once, e.g. a Postgres connection pool through ansst.aws.Vpcbastion:go-socks5runs each connection'sDialin its own goroutine, and the proxy logs each one withui.GetColor(addr).Bold(true).GetColorreturns an entry from the globalui.Colorsby value, but lipgloss v0.9.1 styles keep their rules in a map that is shared across value copies, soBold(true)writes into the shared global map. Concurrent connections race on it and the Go runtime kills the process, which drops the tunnel.Fix
GetColornow returnsColors[i].Copy(), which deep-copies the rules map, so callers can chain setters without touching shared state.proxy.gois the only caller today, but fixing it inGetColorcovers any future ones too.Testing
Added
cmd/sst/mosaic/ui/ui_test.go:TestGetColorConcurrentUse: 32 goroutines callingGetColor(addr).Bold(true).Render(...)TestGetColorDoesNotMutateColors: checks thatColorsisn't changed throughGetColorgo test -race ./cmd/sst/mosaic/ui/:fatal error: concurrent map read and map write(28DATA RACEreports)ok🤖 Generated with Claude Code