Repository navigation
Description
What is the issue?
Hi, I'm Gonzalo, I’ll try to be brief since I’ve been in contact with the support team for months nowchasin this bug. The tldr is: I work with Android scanners in a warehouse and we are using Tailscale. Ever since we installed Tailscale we been having intermittent connection bugs. The stack trace from the app say DNS error but I know is not that. The symptoms: it happens when the device is left idle for some time, but it also happens mid-use. I wasn’t able to turn off and on Tailscale because is forced always-on on the devices, but when I was able to replicate the bug on a dev device and tried to turn off the Tailscale this happened:
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)
It seems there’s some stale tunnel that was supposed to be closed but it wasn’t, from there I just put AI to work and came up with this PR. Don’t disregard the PR just because the code is made by AI, there’s quite a lot of work put in it (the bug and research, not the code).
Steps to reproduce
Just use the device or leave it idle for a few minutes
Are there any recent changes that introduced the issue?
No
OS
Android
OS version
Android 13 and 15
Tailscale version
1.102.3
Other software
No response
Bug report
BUG-7a9153c59b488c5f78261c0b2c6df58df3e70a9dafb6a81f0a80ba0c44b5f17-20260918030048Z-9f09eee46e73588a
Activity
libtailscale: fix double close and stale device in multiTUN
frankekn commentedon Nov 10, 2026
I see the same panic on a current build. Details below in case they help with tailscale/tailscale-android#901.
Environment
1.104.5-t788384763-gd8673104f(Play Store)Frequency
17 native crashes (
SIGABRT) between 2026-11-07 and 2026-11-10, from the tombstones indumpsys dropbox. The process uptime before each crash was between 8 minutes and 7.8 hours.I resolved the stack words of all 17 tombstones against
.gopclntabinlibgojni.so. All 17 are in the recover/re-panic closure ofmultiTUN.run(multitun.go:109-114).Panic (from the logtail replay after the last crash)
Sequence before the crash (UTC, same process)
What I read from the code at d8673104f
multitun.go:143isclose(dev.close)in the<-d.shutdownscase. It runs for every entry indevices.multitun.go:162(close(prev.close)) already closes that channel when a newer device is added. The older device stays indevicesuntil itsreadDonefires.closealone does not look sufficient. The shutdown loop then waits on<-dev.closeDone(line 144), but the only value sent on that channel (line 245) was already received bycase <-runDone(line 133). It also waits on<-dev.readDone(line 145) for a reader that has not finished. That would change the crash into a hang ofmultiTUN.run.Effect on always-on VPN
MainActivitywas in the foreground (2026-11-10), the process was not restarted. The VPN stayed down for 87 minutes, until the app was opened again from the system VPN dialog.I can supply the tombstones and the logcat extract if they are useful.