Skip to content

Android: Tailscale unrecoverable dying on Android #21897

Open
tailscale/tailscale-android
#901

Description

@gonzaarcr

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

  1. added a commit that references this issue on Oct 23, 2026
    04c2f77
  2. added theissue type on Oct 26, 2026
  3. frankekn commented on Nov 10, 2026

    @frankekn

    I see the same panic on a current build. Details below in case they help with tailscale/tailscale-android#901.

    Environment

    • Tailscale Android 1.104.5-t788384763-gd8673104f (Play Store)
    • Samsung Galaxy Z Fold7 (SM-F9660), Android 17, One UI 9.0
    • Always-on VPN is set to Tailscale. "Block connections without VPN" is off.

    Frequency

    17 native crashes (SIGABRT) between 2026-11-07 and 2026-11-10, from the tombstones in dumpsys 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 .gopclntab in libgojni.so. All 17 are in the recover/re-panic closure of multiTUN.run (multitun.go:109-114).

    Panic (from the logtail replay after the last crash)

    panic in multiTUN.run close of closed channel: goroutine 20 [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:111 +0x3c
    panic({0x70fa4d56d0?, 0x70fa3006c0?})
    	/build/.cache/tailscale-go/src/runtime/panic.go:859 +0x120
    github.com/tailscale/tailscale-android/libtailscale.(*multiTUN).run(0x1c531160e0)
    	/build/tailscale-android/libtailscale/multitun.go:143 +0x6b0
    created by github.com/tailscale/tailscale-android/libtailscale.newTUNDevices in goroutine 39
    	/build/tailscale-android/libtailscale/multitun.go:104 +0x214
    

    Sequence before the crash (UTC, same process)

    05:03:02.079 updateTUN: changed
    05:03:02.098 updateTUN: established VPN
    05:03:02.099 updateTUN: added TUN device
    05:03:02.099 wgengine: Reconfig done
    05:03:33.971 EditPrefs: MaskedPrefs{WantRunning=false}
    05:03:33.972 tunnel brought down on disconnect
    05:03:33.973 panic in multiTUN.run close of closed channel
    

    What I read from the code at d8673104f

    • multitun.go:143 is close(dev.close) in the <-d.shutdowns case. It runs for every entry in devices.
    • multitun.go:162 (close(prev.close)) already closes that channel when a newer device is added. The older device stays in devices until its readDone fires.
    • So a shutdown while a superseded device is still queued closes the same channel twice. In the log above, the superseded device was still queued 31 seconds after the new TUN was added.
    • A guard on the close alone 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 by case <-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 of multiTUN.run.

    Effect on always-on VPN

    • When the crash occurred in the background, Android restarted the process and the VPN was established again within about 10 seconds.
    • The one time it occurred while MainActivity was 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-androidIssues involving Tailscale for AndroidbugBugsupport

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions