Skip to content

fix: tunnel dying some time after a network handover - #5994

Merged
2dust merged 1 commit into
2dust:masterfrom
vemneyy:master
Aug 2, 2026
Merged

fix: tunnel dying some time after a network handover#5994
2dust merged 1 commit into
2dust:masterfrom
vemneyy:master

Conversation

@vemneyy

@vemneyy vemneyy commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Introduced in my last commit tunFdForCore() hands the core vpnInterface.dup() on the premise that the core closes the descriptor it was given and would otherwise take the VPN interface down. That premise does not hold. In the pinned xray-core, AndroidTun.Close() (proxy/tun/tun_android.go) returns nil without touching the fd and the gVisor fdbased endpoint it is passed to has an empty Close() reading stops through Attach(nil)dispatcher.Stop()Wait(). Nothing closes it so the duplicate just becomes a ParcelFileDescriptor nobody keeps a reference to and its finalizer performs the only close that fd ever gets at whatever point the GC runs, on a descriptor the running core is still dispatching on. From then on nothing arrives from the tun and every app hangs while the core stays up and only restarting the service recovers. Because the timing is the GC's the failure is not aligned with the handover that caused it which is what makes it hard to trace

@eliotcougar

eliotcougar commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

GPT5.6-Sol-xHigh fully agrees with the analysis and the solution.

@2dust
2dust merged commit 0cf95ac into 2dust:master Aug 2, 2026
1 check 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.

3 participants