Skip to content

Conversation

@spikecurtis
Copy link
Contributor

@spikecurtis spikecurtis commented Dec 3, 2025

fixes: coder/internal#1143

Both gVisor and the Go standard library implementations of net.Conn can under certain circumstances return nil for RemoteAddr() and LocalAddr() calls. If we call their methods, we segfault.

This PR fixes these calls and adds ruleguard rules.

Note that slog.F("remote_addr", conn.RemoteAddr()) is fine because slog detects the nil before attempting to stringify the type.

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@spikecurtis spikecurtis marked this pull request as ready for review December 3, 2025 10:05
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Nice touch with the linter, although I have a mild concern that it's not specific to the net.Addr type so it may result in false-positives.

@spikecurtis spikecurtis force-pushed the spike/internal-1143-remote-addr-nil branch from d45d7e2 to d025d32 Compare December 3, 2025 10:50
@spikecurtis spikecurtis merged commit 40df21e into main Dec 3, 2025
31 checks passed
Copy link
Contributor Author

Merge activity

@spikecurtis spikecurtis deleted the spike/internal-1143-remote-addr-nil branch December 3, 2025 11:06
@github-actions github-actions bot locked and limited conversation to collaborators Dec 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flake: cli TestSSH -- nil pointer while recording connections

3 participants