[Bug] Linux TUN (gVisor) + MASQUE: health check failure triggers ChaCha20 busy spin loop, pinning CPU at 1300%+
Verify steps
- I have read the documentation and understand the meaning of all the configuration items I have written, rather than just piling up seemingly useful options or default values.
- I have carefully reviewed the documentation and have not resolved the issue.
- I have searched the Issue Tracker for the issue I want to raise and did not find it.
- I am a non-Chinese user.
- I have tested with the latest Alpha branch version, and the issue still persists.
- I have provided the server and client configuration files and processes that can reproduce the issue locally, rather than a sanitized complex client configuration file.
- I provided the simplest configuration that can be used to reproduce the errors in my report, rather than relying on remote servers or piling on a lot of unnecessary configurations for reproduction.
- I have provided complete logs, rather than just the parts I think are useful out of confidence in my own intelligence.
- I have directly reproduced the error using the Mihomo command-line program, rather than using other tools or scripts.
Operating System
Linux
System Version
Ubuntu 24.04.4 LTS (Linux 6.8.0-139)
Mihomo Version
Mihomo Meta v1.19.29 linux amd64 with go1.26.5 Sat Jul 18 12:20:02 UTC 2026 Use tags: with_gvisor
Configuration File
tun:
enable: true
stack: gvisor
device: utun
auto-route: true
auto-detect-interface: true
proxy-groups:
- name: "WARP-Auto"
type: url-test
url: "https://cp.cloudflare.com/generate_204"
interval: 300
proxies:
- "MASQUE-Node-1"
- "MASQUE-Node-2"
proxies:
- name: "MASQUE-Node-1"
type: masque
server: 192.129.198.2
port: 443
uuid: 00000000-0000-0000-0000-000000000000
- name: "MASQUE-Node-2"
type: masque
server: 192.129.198.3
port: 443
uuid: 00000000-0000-0000-0000-000000000000Description
When running under Linux with TUN mode enabled (stack: gvisor) and using a url-test proxy group containing MASQUE (Cloudflare WARP) outbound nodes, if upstream nodes become unreachable and continuously fail, activating health check throws Mihomo into a permanent busy-spin loop.
Symptoms:
- Actual network traffic is 0 B/s, yet 10 to 12 CPU cores are completely pegged at 100% (pidstat reports
verge-mihomoconsuming 1320%+ CPU, load average > 16). - The core cannot recover on its own even after idle time; it must be killed via SIGTERM/SIGKILL.
Low-level profiling (perf & gdb disassembly):
Profiling the pinned process with perf record -p <pid> shows intense hotspots in crypto routines (~30% of total cycles):
0xa7db96: rol $0x19, %eax, rol $0x10, rol $0x14, xor, add (ChaCha20 quarter-round loops).
Suspected Root Cause:
When gVisor drops loopback packets (Martian packet dropped with loopback source address) and MASQUE/QUIC handshakes fail, the failure/retry path lacks backoff delays, causing goroutines to spin in tight crypto handshake loops across all CPU threads.
Reproduction Steps
- Start Mihomo on Linux with TUN mode enabled (
stack: gvisor). - Configure a
url-testgroup containing MASQUE (Cloudflare WARP) outbound nodes. - Trigger a network drop or interface change: disconnect and reconnect the network, or switch Wi-Fi networks.
- The underlying QUIC tunnel breaks, and dial failures trigger health checks:
because <group> failed multiple times, activate health check - Observe CPU usage: Even after internet connectivity is restored, Mihomo fails to recover and instead enters a busy-spin loop across read/write goroutines, with CPU usage spiking to 1000%–1300%+ indefinitely.
Additional Context & Preliminary Code Inspection (A Humble Guess)
I am definitely not an expert on Mihomo's internal architecture, so please kindly excuse me if my understanding is flawed or completely off-base. Out of curiosity, I took a brief look at the latest Alpha branch around the MASQUE outbound implementation, and wondered if the following observation might offer any small clue:
In adapter/outbound/masque.go (around lines 390–420):
icmp, err := ipConn.WritePacket(...)
if err != nil {
if errors.Is(err, net.ErrClosed) || errors.Is(err, io.ErrClosedPipe) {
return
}
log.Warnln("[Masque](%s) error writing to IP connection: %v, continuing...", w.name, err)
continue
}And similarly in the ReadPacket() loop:
buf, err := ipConn.ReadPacket()
if err != nil {
if errors.Is(err, net.ErrClosed) || errors.Is(err, io.ErrClosedPipe) {
return
}
log.Warnln("[Masque](%s) error reading from IP connection: %v, continuing...", w.name, err)
continue
}I'm wondering if it might be possible that when the network drops or switches Wi-Fi, the underlying QUIC/connection throws an error other than net.ErrClosed (for instance, a QUIC idle timeout, application error, or path failure). If that happens, because it hits continue instead of breaking or applying a backoff delay, could the loop potentially spin repeatedly at 0ms intervals? This might perhaps explain the massive CPU usage and the ChaCha20 hotspot seen during the perf trace.
Again, this is purely a tentative guess from an outside user and could very well be a misunderstanding of the intended logic. Please feel free to correct or dismiss this if it is unrelated.
Thank you so much to the maintainers for developing and maintaining such a wonderful project!
Logs
time="2026-09-19T19:51:25+01:00" level=warning msg="because WARP-Auto failed multiple times, activate health check"
time="2026-09-19T19:52:30+01:00" level=warning msg="because WARP-Auto failed multiple times, activate health check"
time="2026-09-19T19:53:30+01:00" level=warning msg="because UK-01 failed multiple times, activate health check"
time="2026-09-19T19:53:30+01:00" level=warning msg="because US-01 failed multiple times, activate health check"
I0919 19:54:15.196055 3746726 rate_limited.go:36] Martian packet dropped with loopback source address. If your traffic is unexpectedly dropped, you may want to allow martian packets.
I0919 19:56:04.767007 3746726 rate_limited.go:36] Martian packet dropped with loopback source address. If your traffic is unexpectedly dropped, you may want to allow martian packets.Source: MetaCubeX/mihomo