Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] TUN 模式长时间使用出现 panic 崩溃 #1168

Closed
5 of 6 tasks
TGSAN opened this issue Apr 7, 2024 · 2 comments
Closed
5 of 6 tasks

[Bug] TUN 模式长时间使用出现 panic 崩溃 #1168

TGSAN opened this issue Apr 7, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@TGSAN
Copy link

TGSAN commented Apr 7, 2024

Verify steps

  • 确保你使用的是本仓库最新的的 mihomo 或 mihomo Alpha 版本 Ensure you are using the latest version of Mihomo or Mihomo Alpha from this repository.
  • 如果你可以自己 debug 并解决的话,提交 PR 吧 Is this something you can debug and fix? Send a pull request! Bug fixes and documentation fixes are welcome.
  • 我已经在 Issue Tracker 中找过我要提出的问题 I have searched on the issue tracker for a related issue.
  • 我已经使用 Alpha 分支版本测试过,问题依旧存在 I have tested using the dev branch, and the issue still exists.
  • 我已经仔细看过 Documentation 并无法自行解决问题 I have read the documentation and was unable to solve the issue.
  • 这是 Mihomo 核心的问题,并非我所使用的 Mihomo 衍生版本(如 OpenMihomo、KoolMihomo 等)的特定问题 This is an issue of the Mihomo core per se, not to the derivatives of Mihomo, like OpenMihomo or KoolMihomo.

Mihomo version

Mihomo Meta alpha-c44949b windows amd64 with go1.22.1 Sat Apr 6 21:30:53 UTC 2024 Use tags: with_gvisor

What OS are you seeing the problem on?

Windows

Mihomo config

mode: rule
mixed-port: 7897
socks-port: 7898
port: 7899
allow-lan: false
log-level: info
ipv6: true
secret: ''
external-controller: 127.0.0.1:9097
tcp-concurrent: true
global-client-fingerprint: chrome
keep-alive-interval: 3600
unified-delay: true
tun:
  enable: true
  stack: gvisor
  endpoint-independent-nat: true
  auto-detect-interface: true
  auto-route: true
  strict_route: true
  device: Clash Meta
  dns-hijack:
  - 198.18.0.2:53
  - tcp://198.18.0.2:53
  - '[fdfe:dcba:9876::2]:53'
  - tcp://[fdfe:dcba:9876::2]:53
  mtu: 9000
  strict-route: false
dns:
  enable: true
  ipv6: true
  use-hosts: true
  enhanced-mode: redir-host
  nameserver:
  - cleardns1.intranal
  - cleardns2.intranal
  fake-ip-filter:
  - +.*
  fake-ip-range: 198.18.0.1/16
  fallback: []
experimental:
  sniff-tls-sni: true
sniffer:
  enable: true
  override-destination: false
  sniff:
    QUIC:
      ports:
      - 443
      - 8443
    TLS:
      ports:
      - 443
      - 8443
    HTTP:
      ports:
      - 80
      - 8080-8880
  skip-domain:
  - Mijia Cloud
  - dlg.io.mi.com
  - +.apple.com
  - +.jd.com
  force-domain:
  - +
proxies:
- name: 日本 NTT (UDP, Trojan)
  type: trojan
  server: hideurl
  port: 443
  password: password
  network: ws
  sni: hideurl
  skip-cert-verify: false
  udp: true
  ws-opts:
    path: /ws
    headers:
      Host: hideurl
- name: Office
  type: ss
  server: 192.168.2.2
  port: 114
  cipher: rc4-md5
  password: '514'
  udp: true
- name: 日本 NTT (UDP, Fast, Hysteria2)
  type: hysteria2
  server: hideurl
  port: 443
  password: password
  sni: hideurl
  skip-cert-verify: false
proxy-groups:
- name: 大陆IP规则 (TCP)
  type: select
  disable-udp: true
  proxies:
  - DIRECT
  - Office
- name: 大陆IP规则 (UDP)
  type: select
  proxies:
  - DIRECT
  - Office
- name: 海外IP规则 (TCP)
  type: select
  disable-udp: true
  proxies:
  - "日本 NTT (UDP, Trojan)"
  - "日本 NTT (UDP, Fast, Hysteria2)"
  - DIRECT
- name: 海外IP规则 (UDP)
  type: select
  proxies:
  - "日本 NTT (UDP, Fast, Hysteria2)"
  - "日本 NTT (UDP, Trojan)"
  - DIRECT
rules:
- GEOIP,CN,大陆IP规则 (TCP)
- GEOIP,CN,大陆IP规则 (UDP)
- GEOIP,LAN,DIRECT
- MATCH,海外IP规则 (TCP)
- MATCH,海外IP规则 (UDP)

Mihomo log

time="2024-04-07T15:24:37.5746326+08:00" level=info msg="[TCP] 198.18.0.1:65499 --> 182.254.116.117:80 match GeoIP(cn) using 大陆IP规则 (TCP)[Office]"
time="2024-04-07T15:24:37.5746966+08:00" level=info msg="[TCP] 198.18.0.1:65498 --> 182.254.116.117:80 match GeoIP(cn) using 大陆IP规则 (TCP)[Office]"
time="2024-04-07T15:24:37.7140807+08:00" level=info msg="[TCP] 198.18.0.1:65519 --> 182.254.116.117:80 match GeoIP(cn) using 大陆IP规则 (TCP)[Office]"
time="2024-04-07T15:24:37.8659147+08:00" level=info msg="[TCP] 198.18.0.1:65531 --> 182.254.116.117:80 match GeoIP(cn) using 大陆IP规则 (TCP)[Office]"
time="2024-04-07T15:24:37.9343785+08:00" level=info msg="[TCP] 198.18.0.1:49152 --> 182.254.116.117:80 match GeoIP(cn) using 大陆IP规则 (TCP)[Office]"
time="2024-04-07T15:24:37.9355686+08:00" level=info msg="[TCP] 198.18.0.1:65534 --> 182.254.116.117:80 match GeoIP(cn) using 大陆IP规则 (TCP)[Office]"
time="2024-04-07T15:24:38.1188476+08:00" level=info msg="[TCP] 198.18.0.1:49156 --> 182.254.116.117:80 match GeoIP(cn) using 大陆IP规则 (TCP)[Office]"
time="2024-04-07T15:24:38.1194148+08:00" level=info msg="[TCP] 198.18.0.1:49155 --> 182.254.116.117:80 match GeoIP(cn) using 大陆IP规则 (TCP)[Office]"
time="2024-04-07T15:24:38.145375+08:00" level=info msg="[TCP] 198.18.0.1:49159 --> 182.254.116.117:80 match GeoIP(cn) using 大陆IP规则 (TCP)[Office]"
time="2024-04-07T15:24:38.2153399+08:00" level=info msg="[TCP] 198.18.0.1:65476 --> clientnotification-userprodea1-0.servicebus.windows.net:9354 match Match using 海外IP规则 (TCP)[Global Anycast Smart -> 日本 NTT (UDP, Trojan)]"
time="2024-04-07T15:24:38.2299851+08:00" level=info msg="[TCP] 198.18.0.1:65478 --> login.microsoftonline.com:443 match Match using 海外IP规则 (TCP)[Global Anycast Smart -> 日本 NTT (UDP, Trojan)]"
panic: runtime error: slice bounds out of range [:2102] with capacity 2048

goroutine 107726 [running]:
github.com/sagernet/sing/common/buf.(*Buffer).Bytes(...)
        github.com/sagernet/sing@v0.3.6/common/buf/buffer.go:339
github.com/metacubex/sing-tun.(*UDPBackWriter).WritePacket(0xc0024a5cb0, 0xc001433580, {{{0xfdfedcba98760000, 0x2}, 0xc0001180a8}, 0x35, {0x0, 0x0}})
        github.com/metacubex/sing-tun@v0.2.1-0.20240405021556-f37a4aa3d060/stack_gvisor_udp.go:113 +0xb5c
github.com/sagernet/sing/common/udpnat.(*conn).WritePacket(0xc001a7d580?, 0xc0006fae70?, {{{0xfdfedcba98760000, 0x2}, 0xc0001180a8}, 0x35, {0x0, 0x0}})
        github.com/sagernet/sing@v0.3.6/common/udpnat/service.go:134 +0x57
github.com/metacubex/mihomo/listener/sing_tun.(*ListenerHandler).NewPacketConnection.func3()
        github.com/metacubex/mihomo/listener/sing_tun/dns.go:116 +0x2c6
created by github.com/metacubex/mihomo/listener/sing_tun.(*ListenerHandler).NewPacketConnection in goroutine 105320
        github.com/metacubex/mihomo/listener/sing_tun/dns.go:91 +0x465

Description

使用 gvisor 栈的 tun 使用一段时间后内核会 panic 崩溃,出现频率一天三次左右。如果系统经常锁屏进入睡眠,然后唤醒会更容易出现 panic。
(配置文件出现的cleardns*.intranal是内网的无污染DNS服务器)

@TGSAN TGSAN added the bug Something isn't working label Apr 7, 2024
@wwqgtxx
Copy link
Collaborator

wwqgtxx commented Apr 9, 2024

试试 bd703b8

@TGSAN
Copy link
Author

TGSAN commented Apr 10, 2024

试试 bd703b8

最新的Alpha版本开了一个晚上没有出现崩溃,看上去问题修复了,感谢作者!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants