wireguard-go-awg2-lx/device
Brad Fitzpatrick 09268b375c
device: avoid cycle-leaky runtime.SetFinalizer when unnecessary
In tailscale/wireguard-go#65, @lkosewsk reproduced a memory leak seen
in prod with lots of wireguard-go instances being created and
destroyed, where they were still being retained forever due to cycles
in the runtime.SetFinalizer reference graph.

Really we shouldn't be using runtime.SetFinalizer anywhere. But we
still use it on mobile platforms in WaitPool. But those platforms
don't have thousands of tsnet.Server instances coming & going, so this
is a half fix: avoid the finalizer registration on Linux, etc where
the queue doesn't need to be drained and there's no WaitPool
accounting. Just let GC handle it, without adding finalizer cycle
complexity.

Updates tailscale/corp#42776

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2026-08-04 19:18:01 +08:00
..
allowedips.go device: further add, revise API for on-demand configuration of peers 2026-08-04 19:18:01 +08:00
channels.go device: avoid cycle-leaky runtime.SetFinalizer when unnecessary 2026-08-04 19:18:01 +08:00
constants.go Apply Tailscale bind send headroom 2026-05-17 20:36:35 +08:00
cookie.go global: bump copyright notice 2025-05-05 15:05:35 +02:00
device.go device: fix some lock ordering violations, add a test for a deadlock we hit 2026-08-04 19:18:01 +08:00
devicestate_string.go device: remove deviceStateNew 2021-02-09 15:39:19 +01:00
indextable.go global: bump copyright notice 2025-05-05 15:05:35 +02:00
ip.go global: bump copyright notice 2025-05-05 15:05:35 +02:00
keypair.go Rename module 2026-05-17 20:09:28 +08:00
lock-ordering.md device: fix some lock ordering violations, add a test for a deadlock we hit 2026-08-04 19:18:01 +08:00
logger.go global: bump copyright notice 2025-05-05 15:05:35 +02:00
mobilequirks.go global: bump copyright notice 2025-05-05 15:05:35 +02:00
noise-helpers.go global: bump copyright notice 2025-05-05 15:05:35 +02:00
noise-protocol.go device: fix some lock ordering violations, add a test for a deadlock we hit 2026-08-04 19:18:01 +08:00
noise-types.go global: bump copyright notice 2025-05-05 15:05:35 +02:00
peer.go device: further add, revise API for on-demand configuration of peers 2026-08-04 19:18:01 +08:00
pools.go device: avoid cycle-leaky runtime.SetFinalizer when unnecessary 2026-08-04 19:18:01 +08:00
queueconstants_android.go Rename module 2026-05-17 20:09:28 +08:00
queueconstants_default.go Rename module 2026-05-17 20:09:28 +08:00
queueconstants_ios.go global: bump copyright notice 2025-05-05 15:05:35 +02:00
queueconstants_windows.go global: bump copyright notice 2025-05-05 15:05:35 +02:00
receive.go device: further add, revise API for on-demand configuration of peers 2026-08-04 19:18:01 +08:00
send.go device: further add, revise API for on-demand configuration of peers 2026-08-04 19:18:01 +08:00
sticky_default.go Rename module 2026-05-17 20:09:28 +08:00
sticky_linux.go Rename module 2026-05-17 20:09:28 +08:00
timers.go device: add API for on-demand configuration of peers 2026-08-04 19:06:30 +08:00
tun.go Rename module 2026-05-17 20:09:28 +08:00
uapi.go Rename module 2026-05-17 20:09:28 +08:00