Skip to content

swift: test short writes in OutgoingConnection.send - #70

Open
mattt wants to merge 2 commits into
tailscale:mainfrom
mattt:mattt/fix-outgoing-send
Open

mattt wants to merge 2 commits into
tailscale:mainfrom
mattt:mattt/fix-outgoing-send

Conversation

@mattt

@mattt mattt commented Oct 28, 2026 •

Copy link
Copy Markdown

This PR adds a test for the fix in #72. It sends a four-byte message through the existing connection test and checks the exact bytes received. The test fails without the fix in Release builds but passes in Debug, which is what make test uses, so CI won't catch a regression unless it also runs an optimized build.

mattt added 2 commits October 28, 2026 13:00
The data pointer escaped withUnsafeBytes before write used it, which
could send incorrect bytes for short messages in optimized builds.
Perform the write inside the closure to keep the pointer valid.

Fixes tailscale/tailscale#22025

Signed-off-by: Mattt Zmuda <mattt@me.com>
Signed-off-by: Mattt Zmuda <mattt@me.com>
@mattt mattt changed the title swift: write inside withUnsafeBytes in OutgoingConnection.send swift: test short writes in OutgoingConnection.send Nov 5, 2026
@mattt

mattt commented Nov 5, 2026

Copy link
Copy Markdown
Author

Thanks for landing the fix in #72, @barnstar. I reduced this PR to the test. It only catches the bug in optimized builds, so it would need a Release run in CI to guard against a regression. If you'd rather not take it, feel free to close this.

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