Skip to content

device: fix some lock ordering violations, add a test for a deadlock we hit#55

Merged
bradfitz merged 1 commit intotailscalefrom
bradfitz/wg-deadlock
Apr 24, 2026
Merged

device: fix some lock ordering violations, add a test for a deadlock we hit#55
bradfitz merged 1 commit intotailscalefrom
bradfitz/wg-deadlock

Conversation

@bradfitz
Copy link
Copy Markdown
Member

Discovered by a tool + test that will come in a future change.

Updates tailscale/tailscale#19513

@bradfitz bradfitz requested a review from raggi April 24, 2026 20:52
…we hit

Discovered by a tool + test that will come in a future change.

Updates tailscale/tailscale#19513

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Comment thread device/device.go
// because SendKeepalive can reach CreateMessageInitiation which acquires
// staticIdentity.RLock; holding peers.RLock across that path would
// invert the staticIdentity < peers hierarchy (see lock-ordering.md).
device.peers.RLock()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

note for posterity: i have an upstream patch been waiting in review since 2023 that removes the rwlock from the path because it's actually slower than a mutex when measured in the real world, and it's over-complicated.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yeah, we should make this a regular mutex probably

@bradfitz bradfitz merged commit 770e3f5 into tailscale Apr 24, 2026
13 checks passed
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.

2 participants