Skip to content

libtailscale: fix double close and stale device in multiTUN - #901

Open
gonzaarcr wants to merge 1 commit into
tailscale:mainfrom
gonzaarcr:fix-stale-connection-panic
Open

gonzaarcr wants to merge 1 commit into
tailscale:mainfrom
gonzaarcr:fix-stale-connection-panic

Conversation

@gonzaarcr

Copy link
Copy Markdown

Reopen from #886

09-21 13:35:56.361 D gojni: panic in multiTUN.run close of closed channel: goroutine 2 [running]:
runtime/debug.Stack()
/build/.cache/tailscale-go/src/runtime/debug/stack.go:26 +0x64
github.com/tailscale/tailscale-android/libtailscale.(*multiTUN).run.func1()
/build/tailscale-android/libtailscale/multitun.go:106 +0x3c
panic({0x7041e7e660?, 0x7042041950?})
/build/.cache/tailscale-go/src/runtime/panic.go:860 +0x12c
created by github.com/tailscale/tailscale-android/libtailscale.newTUNDevices in goroutine 40
/build/tailscale-android/libtailscale/multitun.go:99 +0x20c

09-21 13:35:56.379 E Go : panic: close of closed channel [recovered, repanicked]
09-21 13:35:56.384 F libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL)
in tid 31023 (Thread-21), pid 30757 (m.tailscale.ipn)
09-21 13:35:58.345 I Zygote: Process 30757 exited due to signal 6 (Aborted)

Fixes tailscale/tailscale#21897

09-21 13:35:56.361 D gojni: panic in multiTUN.run close of closed channel: goroutine 2 [running]:
      runtime/debug.Stack()
          /build/.cache/tailscale-go/src/runtime/debug/stack.go:26 +0x64
      github.com/tailscale/tailscale-android/libtailscale.(*multiTUN).run.func1()
          /build/tailscale-android/libtailscale/multitun.go:106 +0x3c
      panic({0x7041e7e660?, 0x7042041950?})
          /build/.cache/tailscale-go/src/runtime/panic.go:860 +0x12c
      created by github.com/tailscale/tailscale-android/libtailscale.newTUNDevices in goroutine 40
          /build/tailscale-android/libtailscale/multitun.go:99 +0x20c

  09-21 13:35:56.379 E Go  : panic: close of closed channel [recovered, repanicked]
  09-21 13:35:56.384 F libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL)
                             in tid 31023 (Thread-21), pid 30757 (m.tailscale.ipn)
  09-21 13:35:58.345 I Zygote: Process 30757 exited due to signal 6 (Aborted)

Fixes tailscale/tailscale#21897

Signed-off-by: Gonzalo <gonza.ar.cr@gmail.com>
@atondwal

atondwal commented Nov 2, 2026

Copy link
Copy Markdown

Independent repro of this on a Galaxy Z TriFold (SM-F968B), built from
main (9b62cdc) plus an unrelated network-switch patch. Five peers left the tailnet within one second, which
rebuilt the TUN five times in about 100 ms:

15:09:19.200 wg: Failed to write packets to TUN device: write /dev/tun: input/output error

After that, nothing on the phone could reach the network while the app still
said Connected, until I toggled the VPN about a minute later, which crashed
with the same panic you saw:

15:10:37.704 panic in multiTUN.run close of closed channel

I've been running a build with this PR applied since, with no drops. That
build also includes a separate fix that makes these rebuild bursts rare
(filed as tailscale/tailscale#22129), so I can't credit the stability to this
PR alone. Happy to share the full logcat.

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.

Android: Tailscale unrecoverable dying on Android

2 participants