SagerNet / SagerNet/sing-box

Android TUN: goroutine count grows to 20000+ during idle, causes connection freeze

Open
#4,378 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

need more information
Dominant language
Go
Stars
38.1k
Forks
4.6k
Avg merge
19d 15h
Merged PRs (30d)
1

Description

操作系统

Android

系统版本

Android16

安装类型

sing-box 原始命令行程序

如果您使用图形客户端程序,请提供该程序版本。

1.13.15

版本
sing-box version 1.13.13

Environment: go1.26.4 android/arm64
Tags: with_gvisor,with_quic,with_wireguard,with_utls,with_clash_api
CGO: enabled

(Note: above is from command-line sing-box installed via Termux for reporting purposes; the actual affected client is SFA graphical app version 1.13.15)
描述

在长时间空闲运行后(数小时到数天不等,无明确触发条件),goroutine 数量从正常的 100 多个开始不受控增长,最终达到 20000-30000+,同时观察到:

  1. 上传/下载速率显示为 0 kB/s,但 goroutine 持续增长
  2. 内存占用同步小幅上升(440MB → 470MB左右)
  3. 此时系统代理(TUN)无法建立新连接,但使用应用内置代理(绕过TUN,直连相同节点)可以正常连接
  4. 唯一的恢复方式是重启 VPN(关闭并重新打开 TUN 服务),重启后 goroutine 立即恢复到正常水平

日志中观察到重复出现的错误:
ERROR outbound/direct[DIRECT]: receive ICMP echo reply: i/o timeout

怀疑与出站节点使用 Hysteria2 协议有关(参考已有 issue #3421 中提到的类似现象)。

重现方式

暂无可稳定复现的最小配置。现象在使用 Hysteria2 协议出站、长时间运行后随机出现,触发条件不明确。将持续观察并尝试提供更完整的复现步骤和 debug 级别日志。

日志
=== Log snippet 1 (16:24:49) ===
INFO[0476] router: found package name: com.openai.chatgpt
DEBUG[0476] router: found fakeip domain: 2.datadog.pool.ntp.org
INFO[0476] [908156890 0ms] inbound/tun[tun-in]: inbound packet connection from 172.19.0.1:36054
INFO[0476] [908156890 0ms] inbound/tun[tun-in]: inbound packet connection to 198.18.0.66:123
INFO[0476] [908156890 0ms] router: found package name: com.openai.chatgpt
DEBUG[0476] [908156890 0ms] router: found fakeip domain: 2.datadog.pool.ntp.org
DEBUG[0476] [908156890 0ms] router: match[0] => sniff
DEBUG[0476] [908156890 0ms] router: sniffed packet protocol: 
INFO[0476] [908156890 0ms] outbound/vless[新加坡•移联01]: outbound packet connection to 2.datadog.pool.ntp.org:123
INFO[0476] [908156890 0ms] outbound/vless[新加坡•移联01]: outbound packet connection to 2.datadog.pool.ntp.org:123
DEBUG[0476] [908156890 0ms] dns: lookup domain chuixuevl5.blowingsnowclouds.cc
DEBUG[0476] [908156890 0ms] dns: lookup succeed for chuixuevl5.blowingsnowclouds.cc: 13.250.40.57 2406:da18:15c3:aa00:f711:f5e9:951c:f363
DEBUG[0476] [908156890 172ms] connection: packet upload finished
ERROR[0477] [3556662403 10.0s] outbound/direct[DIRECT]: receive ICMP echo reply: i/o timeout
ERROR[0478] [389805004 10.5s] outbound/direct[DIRECT]: receive ICMP echo reply: i/o timeout
INFO[0479] router: found package name: com.openai.chatgpt
DEBUG[0479] router: found fakeip domain: android.chat.openai.com
INFO[0480] router: found package name: com.openai.chatgpt
DEBUG[0480] router: found fakeip domain: cloudflare-dns.com
INFO[0480] router: found package name: com.openai.chatgpt
DEBUG[0480] router: found fakeip domain: ab.chatgpt.com

=== Log snippet 2 (16:26:29) ===
INFO[0554] router: found package name: org.telegram.messenger
INFO[0554] router: found package name: org.telegram.messenger
ERROR[0554] [3006667928 10.0s] outbound/direct[DIRECT]: receive ICMP echo reply: i/o timeout
ERROR[0555] [396056085 10.3s] outbound/direct[DIRECT]: receive ICMP echo reply: i/o timeout
INFO[0562] router: found package name: org.telegram.messenger
INFO[0562] router: found package name: org.telegram.messenger
INFO[0562] router: found package name: org.telegram.messenger
DEBUG[0562] router: found fakeip domain: firebaseremoteconfig.googleapis.com
DEBUG[0563] outbound/urltest[Gemini_自动]: outbound 香港•电信02 unavailable: Head "https://www.gstatic.com/generate_204": context deadline exceeded
支持我们
完整性要求
  • 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
  • 我保证提供了可以在本地重现该问题的服务器、客户端配置文件与流程,而不是一个脱敏的复杂客户端配置文件。
  • 我保证提供了可用于重现我报告的错误的最简配置,而不是依赖远程服务器、TUN、图形界面客户端或者其他闭源软件。
  • 我保证提供了完整的配置文件与日志,而不是出于对自身智力的自信而仅提供了部分认为有用的部分。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing this report with issue #3421 and inspect the TUN, Hysteria2, and ICMP-timeout paths implicated by the logs. A useful next step is to capture goroutine and debug logs during an idle reproduction. Done means identifying the goroutine leak and providing a reproducible case with evidence that restarting TUN is no longer required.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, go
Domain
mobile-dev, networking
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.