感谢你向 Clash Core 提交 issue!
在提交之前,请确认:
请注意,如果你并没有遵照这个 issue template 填写内容,我们将直接关闭这个 issue。
我都确认过了,我要继续提交。
请附上任何可以帮助我们解决这个问题的信息,如果我们收到的信息不足,我们将对这个 issue 加上 Needs more information 标记并在收到更多资讯之前关闭 issue。
port: 1080
socks-port: 7891
redir-port: 7892
mode: Rule
log-level: info
external-controller: 0.0.0.0:9090
secret: "123456"
allow-lan: true
bind-address: "*"
hosts:
##Custom HOSTS##
# experimental hosts, support wildcard (e.g. *.clash.dev Even *.foo.*.example.com)
# static domain has a higher priority than wildcard domain (foo.example.com > *.example.com)
# NOTE: hosts don't work with `fake-ip`
# '*.clash.dev': 127.0.0.1
# 'alpha.clash.dev': '::1'
##Custom HOSTS END##
dns:
enable: true
ipv6: false
listen: 0.0.0.0:2083
enhanced-mode: redir-host
# fake-ip-range: 198.18.0.1/16
# fake-ip-filter:
# - "*.lan"
# - "*.local"
nameserver:
- 223.5.5.5
- 114.114.114.114
- 119.28.28.28
fallback:
- tls://1.0.0.1:853
- tls://8.8.4.4:853
fallback-filter:
geoip: true
ipcidr:
- 240.0.0.0/4
Proxy:
...
Proxy Group:
...
Rule:
...
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x126e4]
goroutine 126162 [running]:
strings.HasSuffix(...)
/opt/hostedtoolcache/go/1.13.8/x64/src/strings/strings.go:454
strings.TrimSuffix(...)
/opt/hostedtoolcache/go/1.13.8/x64/src/strings/strings.go:916
github.com/miekg/dns.IsFqdn(0x0, 0x11, 0x499a69)
/home/runner/go/pkg/mod/github.com/miekg/[email protected]/defaults.go:270 +0x10c
github.com/miekg/dns.packDomainName(0x0, 0x11, 0x4000400500, 0xf5, 0xf5, 0xc, 0x0, 0x0, 0x100, 0x3e62a0, ...)
/home/runner/go/pkg/mod/github.com/miekg/[email protected]/msg.go:215 +0x34
github.com/miekg/dns.(*Question).pack(0x40008fbd00, 0x4000400500, 0xf5, 0xf5, 0xc, 0x0, 0x0, 0x48c000, 0xc, 0x0, ...)
/home/runner/go/pkg/mod/github.com/miekg/[email protected]/msg.go:1082 +0x6c
github.com/miekg/dns.(*Msg).packBufferWithCompressionMap(0x4000b81680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4000442d00, 0x0, 0x8, ...)
/home/runner/go/pkg/mod/github.com/miekg/[email protected]/msg.go:800 +0x280
github.com/miekg/dns.(*Msg).PackBuffer(0x4000b81680, 0x0, 0x0, 0x0, 0x4001010e18, 0x4000d40140, 0x18, 0x4000d400e0, 0x4001010e08)
/home/runner/go/pkg/mod/github.com/miekg/[email protected]/msg.go:734 +0x64
github.com/miekg/dns.(*Msg).Pack(...)
/home/runner/go/pkg/mod/github.com/miekg/[email protected]/msg.go:722
github.com/miekg/dns.(*response).WriteMsg(0x4000d6bce0, 0x4000b81680, 0x1, 0x40011d5b00)
/home/runner/go/pkg/mod/github.com/miekg/[email protected]/server.go:671 +0x48
github.com/Dreamacro/clash/dns.withResolver.func1(0x550180, 0x4000d6bce0, 0x4000d24240)
/home/runner/work/clash/clash/dns/middleware.go:61 +0x18c
github.com/Dreamacro/clash/dns.(*Server).ServeDNS(0x40001e3bf0, 0x550180, 0x4000d6bce0, 0x4000d24240)
/home/runner/work/clash/clash/dns/server.go:27 +0x70
github.com/miekg/dns.(*Server).serveDNS(0x400027a000, 0x4000810200, 0x22, 0x200, 0x4000d6bce0)
/home/runner/go/pkg/mod/github.com/miekg/[email protected]/server.go:609 +0x25c
github.com/miekg/dns.(*Server).serveUDPPacket(0x400027a000, 0x40001a5a34, 0x4000810200, 0x22, 0x200, 0x40000a41b8, 0x4000442ce0)
/home/runner/go/pkg/mod/github.com/miekg/[email protected]/server.go:549 +0xa8
created by github.com/miekg/dns.(*Server).serveUDP
/home/runner/go/pkg/mod/github.com/miekg/[email protected]/server.go:479 +0x200
root@OpenWrt:~# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere /* !fw3 */
input_rule all -- anywhere anywhere /* !fw3: Custom input rule chain */
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
syn_flood tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN /* !fw3 */
zone_lan_input all -- anywhere anywhere /* !fw3 */
Chain FORWARD (policy ACCEPT)
target prot opt source destination
forwarding_rule all -- anywhere anywhere /* !fw3: Custom forwarding rule chain */
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
zone_lan_forward all -- anywhere anywhere /* !fw3 */
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere /* !fw3 */
output_rule all -- anywhere anywhere /* !fw3: Custom output rule chain */
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED /* !fw3 */
zone_lan_output all -- anywhere anywhere /* !fw3 */
Chain MINIUPNPD (1 references)
target prot opt source destination
Chain forwarding_lan_rule (1 references)
target prot opt source destination
Chain forwarding_rule (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
Chain forwarding_vpn_rule (1 references)
target prot opt source destination
Chain forwarding_wan_rule (1 references)
target prot opt source destination
Chain input_lan_rule (1 references)
target prot opt source destination
Chain input_rule (1 references)
target prot opt source destination
Chain input_vpn_rule (1 references)
target prot opt source destination
Chain input_wan_rule (1 references)
target prot opt source destination
Chain output_lan_rule (1 references)
target prot opt source destination
Chain output_rule (1 references)
target prot opt source destination
Chain output_vpn_rule (1 references)
target prot opt source destination
Chain output_wan_rule (1 references)
target prot opt source destination
Chain reject (0 references)
target prot opt source destination
REJECT tcp -- anywhere anywhere /* !fw3 */ reject-with tcp-reset
REJECT all -- anywhere anywhere /* !fw3 */ reject-with icmp-port-unreachable
Chain syn_flood (1 references)
target prot opt source destination
RETURN tcp -- anywhere anywhere tcp flags:FIN,SYN,RST,ACK/SYN limit: avg 25/sec burst 50 /* !fw3 */
DROP all -- anywhere anywhere /* !fw3 */
Chain zone_lan_dest_ACCEPT (6 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere /* !fw3 */
Chain zone_lan_dest_DROP (1 references)
target prot opt source destination
DROP all -- anywhere anywhere /* !fw3 */
Chain zone_lan_forward (1 references)
target prot opt source destination
MINIUPNPD all -- anywhere anywhere
forwarding_lan_rule all -- anywhere anywhere /* !fw3: Custom lan forwarding rule chain */
zone_wan_dest_ACCEPT all -- anywhere anywhere /* !fw3: Zone lan to wan forwarding policy */
ACCEPT all -- anywhere anywhere ctstate DNAT /* !fw3: Accept port forwards */
zone_lan_dest_ACCEPT all -- anywhere anywhere /* !fw3 */
Chain zone_lan_input (1 references)
target prot opt source destination
input_lan_rule all -- anywhere anywhere /* !fw3: Custom lan input rule chain */
ACCEPT igmp -- anywhere anywhere /* !fw3: ubus:igmpproxy[instance1] rule 3 */
ACCEPT all -- anywhere anywhere ctstate DNAT /* !fw3: Accept port redirections */
zone_lan_src_ACCEPT all -- anywhere anywhere /* !fw3 */
Chain zone_lan_output (1 references)
target prot opt source destination
output_lan_rule all -- anywhere anywhere /* !fw3: Custom lan output rule chain */
zone_lan_dest_ACCEPT all -- anywhere anywhere /* !fw3 */
Chain zone_lan_src_ACCEPT (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate NEW,UNTRACKED /* !fw3 */
Chain zone_vpn_dest_ACCEPT (2 references)
target prot opt source destination
Chain zone_vpn_forward (0 references)
target prot opt source destination
forwarding_vpn_rule all -- anywhere anywhere /* !fw3: Custom vpn forwarding rule chain */
zone_wan_dest_ACCEPT all -- anywhere anywhere /* !fw3: Zone vpn to wan forwarding policy */
zone_lan_dest_ACCEPT all -- anywhere anywhere /* !fw3: Zone vpn to lan forwarding policy */
ACCEPT all -- anywhere anywhere ctstate DNAT /* !fw3: Accept port forwards */
zone_vpn_dest_ACCEPT all -- anywhere anywhere /* !fw3 */
Chain zone_vpn_input (0 references)
target prot opt source destination
input_vpn_rule all -- anywhere anywhere /* !fw3: Custom vpn input rule chain */
ACCEPT all -- anywhere anywhere ctstate DNAT /* !fw3: Accept port redirections */
zone_vpn_src_ACCEPT all -- anywhere anywhere /* !fw3 */
Chain zone_vpn_output (0 references)
target prot opt source destination
output_vpn_rule all -- anywhere anywhere /* !fw3: Custom vpn output rule chain */
zone_vpn_dest_ACCEPT all -- anywhere anywhere /* !fw3 */
Chain zone_vpn_src_ACCEPT (1 references)
target prot opt source destination
Chain zone_wan_dest_ACCEPT (3 references)
target prot opt source destination
Chain zone_wan_dest_REJECT (1 references)
target prot opt source destination
Chain zone_wan_forward (0 references)
target prot opt source destination
forwarding_wan_rule all -- anywhere anywhere /* !fw3: Custom wan forwarding rule chain */
zone_lan_dest_DROP udp -- anywhere 239.255.255.250 /* !fw3: ubus:igmpproxy[instance1] rule 1 */
zone_lan_dest_ACCEPT udp -- anywhere base-address.mcast.net/4 /* !fw3: ubus:igmpproxy[instance1] rule 2 */
zone_lan_dest_ACCEPT esp -- anywhere anywhere /* !fw3: Allow-IPSec-ESP */
zone_lan_dest_ACCEPT udp -- anywhere anywhere udp dpt:isakmp /* !fw3: Allow-ISAKMP */
ACCEPT all -- anywhere anywhere ctstate DNAT /* !fw3: Accept port forwards */
zone_wan_dest_REJECT all -- anywhere anywhere /* !fw3 */
Chain zone_wan_input (0 references)
target prot opt source destination
input_wan_rule all -- anywhere anywhere /* !fw3: Custom wan input rule chain */
ACCEPT igmp -- anywhere anywhere /* !fw3: ubus:igmpproxy[instance1] rule 0 */
ACCEPT udp -- anywhere anywhere udp dpt:bootpc /* !fw3: Allow-DHCP-Renew */
ACCEPT icmp -- anywhere anywhere icmp echo-request /* !fw3: Allow-Ping */
ACCEPT igmp -- anywhere anywhere /* !fw3: Allow-IGMP */
DROP tcp -- anywhere anywhere tcp dpt:8118 /* !fw3: adblock */
ACCEPT tcp -- anywhere anywhere tcp dpt:1688 /* !fw3: kms */
ACCEPT tcp -- anywhere anywhere tcp dpt:openvpn /* !fw3: openvpn */
ACCEPT udp -- anywhere anywhere udp dpt:openvpn /* !fw3: openvpn */
ACCEPT tcp -- anywhere anywhere tcp dpt:1723 /* !fw3: pptp */
ACCEPT gre -- anywhere anywhere /* !fw3: gre */
ACCEPT all -- anywhere anywhere ctstate DNAT /* !fw3: Accept port redirections */
zone_wan_src_REJECT all -- anywhere anywhere /* !fw3 */
Chain zone_wan_output (0 references)
target prot opt source destination
output_wan_rule all -- anywhere anywhere /* !fw3: Custom wan output rule chain */
zone_wan_dest_ACCEPT all -- anywhere anywhere /* !fw3 */
Chain zone_wan_src_REJECT (1 references)
target prot opt source destination
无法确定重现步骤
我预期会发生……?
Clash 内核不会崩溃
实际上发生了什麽?
Clash core panic
請附上 reproduction steps,用 dev 版本再測試一次
請附上 reproduction steps,用 dev 版本再測試一次
无法直接重现,但是基本几个小时就会崩溃一次。
dev 版本相比 master 的 0.18 只有一处跟 provider 相关的提交 https://github.com/Dreamacro/clash/commit/9eaca6e4ab4ccf584d6ced0da56dc5a9c82a2b52 ,但是从 panic 的堆栈来看,异常处是跟 DNS 解析相关的一个字符串判断,没必要再用 dev 跑了吧?
用clash-linux-amd64-v0.18.0-2-ga79f287 版本,这个应该dev吧,ui为openclash 0.36.6,刚刚也遇到这样的问题,重现步骤是打开youtube网页,会有崩溃伴有如下报错,无法继续提供服务
2020-02-25 01:51:19 OpenClash Start Successful
time="2020-02-24T17:53:04Z" level=warning msg="dial 🦉 Direct error: dial tcp4 192.168.100.101:0->74.125.203.188:443: i/o timeout"
time="2020-02-24T17:53:14Z" level=warning msg="dial 🦉 Direct error: dial tcp4 192.168.100.101:0->125.39.132.162:80: i/o timeout"
time="2020-02-24T17:53:17Z" level=warning msg="dial 🦉 Direct error: dial tcp4 192.168.100.101:0->74.125.203.188:5228: i/o timeout"
time="2020-02-24T17:53:42Z" level=warning msg="dial 🦉 Direct error: dial tcp4 192.168.100.101:0->74.125.203.188:5228: i/o timeout"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x859dc4]
goroutine 3567 [running]:
github.com/Dreamacro/clash/proxy/tun.(*packet).WriteBack(0xc00051ba40, 0xc000460000, 0x546, 0x5000, 0xa655a0, 0x0, 0x0, 0x0, 0x0)
/Users/Dreamacro/Dev/projects/clash/proxy/tun/tun.go:55 +0x154
github.com/Dreamacro/clash/tunnel.handleUDPToLocal(0xa6a560, 0xc00051ba40, 0x7f3a14eb3c58, 0xc000c4f1a0, 0xc000125c60, 0x15)
/Users/Dreamacro/Dev/projects/clash/tunnel/connection.go:103 +0x29b
created by github.com/Dreamacro/clash/tunnel.handleUDPConn.func1
/Users/Dreamacro/Dev/projects/clash/tunnel/tunnel.go:234 +0x4f1
2020-02-25 01:54:21 Watchdog: Clash Core Problem, Restart.
最近换了一个ARM设备之后发现有遇到类似的错误。日志如下
Feb 28 13:02:58 armbian clash[3995]: panic: runtime error: invalid memory address or nil pointer dereference
Feb 28 13:02:58 armbian clash[3995]: [signal SIGSEGV: segmentation violation code=0x1 addr=0xc pc=0x126e4]
Feb 28 13:02:58 armbian clash[3995]: goroutine 1409893 [running]:
Feb 28 13:02:58 armbian clash[3995]: strings.HasSuffix(...)
Feb 28 13:02:58 armbian clash[3995]: /usr/lib/go-1.13/src/strings/strings.go:454
Feb 28 13:02:58 armbian clash[3995]: strings.TrimSuffix(...)
Feb 28 13:02:58 armbian clash[3995]: /usr/lib/go-1.13/src/strings/strings.go:916
Feb 28 13:02:58 armbian clash[3995]: github.com/miekg/dns.IsFqdn(0x0, 0xd, 0x499a69)
Feb 28 13:02:58 armbian clash[3995]: /home/user/go/pkg/mod/github.com/miekg/[email protected]/defaults.go:270 +0x10c
Feb 28 13:02:58 armbian clash[3995]: github.com/miekg/dns.packDomainName(0x0, 0xd, 0x4000965600, 0x3b, 0x3b, 0xc, 0x0, 0x0, 0x0, 0x3e62a0, ...)
Feb 28 13:02:58 armbian clash[3995]: /home/user/go/pkg/mod/github.com/miekg/[email protected]/msg.go:215 +0x34
Feb 28 13:02:58 armbian clash[3995]: github.com/miekg/dns.(*Question).pack(0x40002f8d00, 0x4000965600, 0x3b, 0x3b, 0xc, 0x0, 0x0, 0x48c000, 0xc, 0x0, ...)
Feb 28 13:02:58 armbian clash[3995]: /home/user/go/pkg/mod/github.com/miekg/[email protected]/msg.go:1082 +0x6c
Feb 28 13:02:58 armbian clash[3995]: github.com/miekg/dns.(*Msg).packBufferWithCompressionMap(0x400016f9e0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x400000c400, 0x0, 0x8, ...)
Feb 28 13:02:58 armbian clash[3995]: /home/user/go/pkg/mod/github.com/miekg/[email protected]/msg.go:800 +0x280
Feb 28 13:02:58 armbian clash[3995]: github.com/miekg/dns.(*Msg).PackBuffer(0x400016f9e0, 0x0, 0x0, 0x0, 0x751d8b56874b, 0x4000c74ce0, 0x14, 0x4000575db0, 0x40002f8e08)
Feb 28 13:02:58 armbian clash[3995]: /home/user/go/pkg/mod/github.com/miekg/[email protected]/msg.go:734 +0x64
Feb 28 13:02:58 armbian clash[3995]: github.com/miekg/dns.(*Msg).Pack(...)
Feb 28 13:02:58 armbian clash[3995]: /home/user/go/pkg/mod/github.com/miekg/[email protected]/msg.go:722
Feb 28 13:02:58 armbian clash[3995]: github.com/miekg/dns.(*response).WriteMsg(0x4000ac52c0, 0x400016f9e0, 0x1, 0x400000c720)
Feb 28 13:02:58 armbian clash[3995]: /home/user/go/pkg/mod/github.com/miekg/[email protected]/server.go:671 +0x48
Feb 28 13:02:58 armbian clash[3995]: github.com/Dreamacro/clash/dns.withResolver.func1(0x5501a0, 0x4000ac52c0, 0x400016f710)
Feb 28 13:02:58 armbian clash[3995]: /home/user/clash/dns/middleware.go:61 +0x18c
Feb 28 13:02:58 armbian clash[3995]: github.com/Dreamacro/clash/dns.(*Server).ServeDNS(0x40003d1590, 0x5501a0, 0x4000ac52c0, 0x400016f710)
Feb 28 13:02:58 armbian clash[3995]: /home/user/clash/dns/server.go:27 +0x70
Feb 28 13:02:58 armbian clash[3995]: github.com/miekg/dns.(*Server).serveDNS(0x400044a000, 0x4000542000, 0x1e, 0x200, 0x4000ac52c0)
Feb 28 13:02:58 armbian clash[3995]: /home/user/go/pkg/mod/github.com/miekg/[email protected]/server.go:609 +0x25c
Feb 28 13:02:58 armbian clash[3995]: github.com/miekg/dns.(*Server).serveUDPPacket(0x400044a000, 0x40002c83b4, 0x4000542000, 0x1e, 0x200, 0x400000e3c8, 0x400000c480)
Feb 28 13:02:58 armbian clash[3995]: /home/user/go/pkg/mod/github.com/miekg/[email protected]/server.go:549 +0xa8
Feb 28 13:02:58 armbian clash[3995]: created by github.com/miekg/dns.(*Server).serveUDP
Feb 28 13:02:58 armbian clash[3995]: /home/user/go/pkg/mod/github.com/miekg/[email protected]/server.go:479 +0x200
Feb 28 13:02:58 armbian systemd[1]: clash.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Feb 28 13:02:58 armbian systemd[1]: clash.service: Failed with result 'exit-code'.
Feb 28 13:03:01 armbian systemd[1]: clash.service: Service RestartSec=3s expired, scheduling restart.
Feb 28 13:03:01 armbian systemd[1]: clash.service: Scheduled restart job, restart counter is at 5.
目前看来v0.18.0-8-g68b82c9解决了这个问题。
目前看来v0.18.0-8-g68b82c9解决了这个问题。
请问在哪里可以找到这个版本?
@NV3S @welladamm 你们两个 panic 的情况不一样,WriteBack 的问题解决了,但是这个 dns 的问题我还没法复现
我把coredump打开之后就再也不触发crash了,目前暂时没有办法提供更多的信息。
新发现一种 panic,不是一处堆栈:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x12a04]
goroutine 361108 [running]:
strings.IndexByte(...)
/usr/lib/go-1.13/src/strings/strings.go:151
strings.Index(0x0, 0x1d, 0x499a69, 0x1, 0x4000452bc8)
/usr/lib/go-1.13/src/strings/strings.go:1033 +0x4f0
strings.Contains(...)
/usr/lib/go-1.13/src/strings/strings.go:99
github.com/miekg/dns.domainNameLen(0x0, 0x1d, 0xc, 0x0, 0x42e901, 0x40009c0930)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/msg.go:988 +0x78
github.com/miekg/dns.(*Question).len(...)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/types.go:221
github.com/miekg/dns.msgLenWithCompressionMap(0x4000872870, 0x0, 0x4000452ca8)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/msg.go:962 +0x22c
github.com/miekg/dns.(*Msg).packBufferWithCompressionMap(0x4000872870, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4000241b00, 0x0, 0x8, ...)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/msg.go:788 +0x180
github.com/miekg/dns.(*Msg).PackBuffer(0x4000872870, 0x0, 0x0, 0x0, 0x4000452dd0, 0x4000024360, 0x27, 0x4000176ee0, 0x4000452e08)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/msg.go:734 +0x64
github.com/miekg/dns.(*Msg).Pack(...)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/msg.go:722
github.com/miekg/dns.(*response).WriteMsg(0x4000a4d7a0, 0x4000872870, 0x1, 0x400053e520)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/server.go:671 +0x48
github.com/Dreamacro/clash/dns.withResolver.func1(0x5501e0, 0x4000a4d7a0, 0x4000872630)
/home/vernesong/home/clash/dns/middleware.go:61 +0x18c
github.com/Dreamacro/clash/dns.(*Server).ServeDNS(0x40002be300, 0x5501e0, 0x4000a4d7a0, 0x4000872630)
/home/vernesong/home/clash/dns/server.go:27 +0x70
github.com/miekg/dns.(*Server).serveDNS(0x40001f06c0, 0x4000666600, 0x2e, 0x200, 0x4000a4d7a0)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/server.go:609 +0x25c
github.com/miekg/dns.(*Server).serveUDPPacket(0x40001f06c0, 0x4000286754, 0x4000666600, 0x2e, 0x200, 0x40000a41e0, 0x4000241bc0)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/server.go:549 +0xa8
created by github.com/miekg/dns.(*Server).serveUDP
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/server.go:479 +0x200
I have the same issue, clash crashed unexpectedly.
OS: Armbian (Debian 10)
Kernel: 5.3.0
Clash version: Clash v0.18.0 linux arm64

@tonyshaoxu 和你一样的崩溃记录
time="2020-03-07T13:29:49Z" level=info msg="[TCP] 10.0.0.11:54340 --> 106.39.246.43 match GeoIP using DIRECT"
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x12a04]
goroutine 98145 [running]:
strings.IndexByte(...)
/usr/lib/go-1.13/src/strings/strings.go:151
strings.Index(0x0, 0x1b, 0x499a69, 0x1, 0x4000ad7bc8)
/usr/lib/go-1.13/src/strings/strings.go:1033 +0x4f0
strings.Contains(...)
/usr/lib/go-1.13/src/strings/strings.go:99
github.com/miekg/dns.domainNameLen(0x0, 0x1b, 0xc, 0x0, 0x42e901, 0x4002143b30)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/msg.go:988 +0x78
github.com/miekg/dns.(*Question).len(...)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/types.go:221
github.com/miekg/dns.msgLenWithCompressionMap(0x400050e510, 0x0, 0x4000ad7ca8)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/msg.go:962 +0x22c
github.com/miekg/dns.(*Msg).packBufferWithCompressionMap(0x400050e510, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x40002d0000, 0x0, 0x8, ...)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/msg.go:788 +0x180
github.com/miekg/dns.(*Msg).PackBuffer(0x400050e510, 0x0, 0x0, 0x0, 0x243e2b19c006, 0x400009c060, 0x25, 0x40000a21a0, 0x4000ad7e08)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/msg.go:734 +0x64
github.com/miekg/dns.(*Msg).Pack(...)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/msg.go:722
github.com/miekg/dns.(*response).WriteMsg(0x40017ac000, 0x400050e510, 0x1, 0x40002aa400)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/server.go:671 +0x48
github.com/Dreamacro/clash/dns.withResolver.func1(0x5501e0, 0x40017ac000, 0x400134e000)
/home/vernesong/home/clash/dns/middleware.go:61 +0x18c
github.com/Dreamacro/clash/dns.(*Server).ServeDNS(0x40002c6310, 0x5501e0, 0x40017ac000, 0x400134e000)
/home/vernesong/home/clash/dns/server.go:27 +0x70
github.com/miekg/dns.(*Server).serveDNS(0x40001f87e0, 0x400015d000, 0x2c, 0x200, 0x40017ac000)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/server.go:609 +0x25c
github.com/miekg/dns.(*Server).serveUDPPacket(0x40001f87e0, 0x400028e754, 0x400015d000, 0x2c, 0x200, 0x40000a41e8, 0x40002d0000)
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/server.go:549 +0xa8
created by github.com/miekg/dns.(*Server).serveUDP
/home/vernesong/go/pkg/mod/github.com/miekg/[email protected]/server.go:479 +0x200
如果你们有用到 fallback dns,那么 dev 版本现在修复了一个可能的点
如果你们有用到 fallback dns,那么 dev 版本现在修复了一个可能的点
感谢!非常抱歉问个 n00b 问题: dev 版本的 binary 在哪里下载? release 里只有 master 分支编译的 binary……
目前 dev 分支应该只提供了 docker image,并没有实时的 dev release,需要的话可以先自行 build
@Dreamacro
I compiled dev, but it seems dev does not fix the issue, clash crashed again.
OS: Armbian (Debian 10)
Kernel: 5.3.0
Clash version: Clash dev
目前 dev 分支应该只提供了 docker image,并没有实时的 dev release,需要的话可以先自行 build
v0.18.0-13-g14d5137 这个版本仍然能重现顶楼的 crash
v0.18.0-9471d80 这个版本依然会出现2个不同个crash
DNS里面不实用fallback也会crash
btw,不知道为什么没有coredump文件生成出来。
@CyberKoo 你也有用 tls 的 dns 吗
@CyberKoo 你也有用 tls 的 dns 吗
上游是UDP模式的smartdns
dns:
enable: true
ipv6: true
enhanced-mode: redir-host
listen: 127.0.0.1:9653
nameserver:
- 127.0.0.1:9953
这个 panic 我用代码重现了,具体原因是因为 miekg/dns 库在高并发的情况跨 goroutine 读写 string 导致 Question.Name 取得的 string 只有 len 数据指针为 0x0 最终导致取值 panic,可以用我构建的类似代码测试,跑一会儿就会出现类似的 panic
package main
import (
"fmt"
"log"
"strings"
"time"
"unsafe"
)
func main() {
type DnsQuestion struct {
Name string
}
type Msg struct {
Question []DnsQuestion
}
type String struct {
Data unsafe.Pointer
Len int
}
msg := Msg{}
msg.Question = []DnsQuestion{
{ Name: "aaskdhaksdhaskdhbc" },
{ Name: "asldhasdfjhasdkfsf" },
}
var msg2 Msg
msg2.Question = make([]DnsQuestion, len(msg.Question))
trimFunc := func() {
for {
time.Sleep(time.Millisecond)
s := strings.TrimSuffix(msg2.Question[0].Name, ".")
_ = fmt.Sprintf("s %s", s)
}
}
containFunc := func() {
for {
time.Sleep(time.Millisecond)
s := strings.Contains(msg2.Question[0].Name, ".")
if s {
log.Println("haha")
}
}
}
go trimFunc()
go containFunc()
go trimFunc()
go containFunc()
go trimFunc()
go containFunc()
go trimFunc()
go containFunc()
go trimFunc()
go containFunc()
go trimFunc()
go containFunc()
go trimFunc()
go containFunc()
go trimFunc()
go containFunc()
go trimFunc()
go containFunc()
go trimFunc()
go containFunc()
go trimFunc()
go containFunc()
go trimFunc()
go trimFunc()
go containFunc()
go containFunc()
go trimFunc()
go trimFunc()
go trimFunc()
go trimFunc()
go containFunc()
go trimFunc()
go containFunc()
go containFunc()
go containFunc()
go containFunc()
for {
time.Sleep(time.Millisecond * 10)
msg2.Question = make([]DnsQuestion, len(msg.Question))
copy(msg2.Question, msg.Question)
//var msgT Msg
//msgT.Question = make([]DnsQuestion, len(msg.Question))
//copy(msgT.Question, msg.Question)
//msg2.Question = msgT.Question
}
}
由于不停 copy 并且多线程不停读取,运行几秒或者几十秒之后:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x11 pc=0x10022c4]
goroutine 26 [running]:
strings.HasSuffix(...)
/usr/local/Cellar/go/1.14/libexec/src/strings/strings.go:454
strings.TrimSuffix(...)
/usr/local/Cellar/go/1.14/libexec/src/strings/strings.go:916
main.main.func1()
/Users/ethan/Library/Preferences/GoLand2019.3/scratches/scratch.go:37 +0x11d
created by main.main
/Users/ethan/Library/Preferences/GoLand2019.3/scratches/scratch.go:60 +0x1f8
我已经 fork 了 miekg/dns 并且修改了 copy 逻辑:https://github.com/wsvn53/dns 并且编译了一个 clash v0.18 arm/darwin/amd64 版本在生产环境测试,等测试通过再提交 PR
clash-v0.18.0-dns_fixed.zip
@wsvn53 感谢定位,我看了好几遍 clash dns 的代码,没找到啥原因
@wsvn53 我这能最小复现这个库的 bug 了,准备提 pr 吗?
@wsvn53 我这能最小复现这个库的 bug 了,准备提 pr 吗?
额,最小复现是?没有再复现了吗?
@wsvn53
package main
import (
"fmt"
"strings"
"time"
"github.com/miekg/dns"
)
func main() {
msg := &dns.Msg{}
msg.Question = []dns.Question{
dns.Question{"example.com.", dns.TypeA, dns.ClassINET},
dns.Question{"example2.com.", dns.TypeA, dns.ClassINET},
}
msg2 := &dns.Msg{}
msg2.Question = make([]dns.Question, len(msg.Question))
trimFunc := func() {
for {
time.Sleep(time.Millisecond)
s := strings.TrimSuffix(msg2.Question[0].Name, ".")
s = fmt.Sprintf("s %s", s)
}
}
for i := 0; i < 20; i++ {
go trimFunc()
}
for {
time.Sleep(time.Millisecond * 10)
msg.CopyTo(msg2)
}
}
明白了,有替换过我修改过的库试一下是否修复吗? https://github.com/wsvn53/dns ,没问题我就去提 PR。
先拷贝再赋值应该没问题 @wsvn53
明白了,有替换过我修改过的库试一下是否修复吗? https://github.com/wsvn53/dns ,没问题我就去提 PR。
我用你的fork跑了一下午。没有出问题。[划掉]
话音未落,瞬间打脸
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: panic: runtime error: invalid memory address or nil pointer dereference
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: [signal SIGSEGV: segmentation violation code=0x1 addr=0xd pc=0x126e4]
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: goroutine 8568 [running]:
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: strings.HasSuffix(...)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /usr/lib/go-1.13/src/strings/strings.go:454
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: strings.TrimSuffix(...)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /usr/lib/go-1.13/src/strings/strings.go:916
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: github.com/miekg/dns.IsFqdn(0x0, 0xe, 0xffffffffffffffff)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /root/go/pkg/mod/github.com/wsvn53/[email protected]/defaults.go:270 +0x10c
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: github.com/miekg/dns.packDomainName(0x0, 0xe, 0x4000257080, 0x79, 0x79, 0xc, 0x0, 0x0, 0x0, 0x3e64a0, ...)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /root/go/pkg/mod/github.com/wsvn53/[email protected]/msg.go:215 +0x34
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: github.com/miekg/dns.(*Question).pack(0x400046cd00, 0x4000257080, 0x79, 0x79, 0xc, 0x0, 0x0, 0x48c900, 0xc, 0x0, ...)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /root/go/pkg/mod/github.com/wsvn53/[email protected]/msg.go:1082 +0x6c
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: github.com/miekg/dns.(*Msg).packBufferWithCompressionMap(0x40009fbb90, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4000467b00, 0x0, 0x8, ...)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /root/go/pkg/mod/github.com/wsvn53/[email protected]/msg.go:799 +0x280
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: github.com/miekg/dns.(*Msg).PackBuffer(0x40009fbb90, 0x0, 0x0, 0x0, 0x6b6f7ae6ae, 0x40009f1f00, 0x18, 0x4000023460, 0x400046ce08)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /root/go/pkg/mod/github.com/wsvn53/[email protected]/msg.go:733 +0x64
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: github.com/miekg/dns.(*Msg).Pack(...)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /root/go/pkg/mod/github.com/wsvn53/[email protected]/msg.go:721
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: github.com/miekg/dns.(*response).WriteMsg(0x40004f9ce0, 0x40009fbb90, 0x1, 0x4000467cc0)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /root/go/pkg/mod/github.com/wsvn53/[email protected]/server.go:671 +0x48
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: github.com/Dreamacro/clash/dns.withResolver.func1(0x551700, 0x40004f9ce0, 0x40009fba70)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /usr/src/clash/dns/middleware.go:61 +0x18c
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: github.com/Dreamacro/clash/dns.(*Server).ServeDNS(0x400051deb0, 0x551700, 0x40004f9ce0, 0x40009fba70)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /usr/src/clash/dns/server.go:27 +0x70
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: github.com/miekg/dns.(*Server).serveDNS(0x4000407440, 0x4000604000, 0x1f, 0x200, 0x40004f9ce0)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /root/go/pkg/mod/github.com/wsvn53/[email protected]/server.go:609 +0x25c
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: github.com/miekg/dns.(*Server).serveUDPPacket(0x4000407440, 0x4000463d60, 0x4000604000, 0x1f, 0x200, 0x40000a0628, 0x40003ed3e0)
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /root/go/pkg/mod/github.com/wsvn53/[email protected]/server.go:549 +0xa8
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: created by github.com/miekg/dns.(*Server).serveUDP
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /root/go/pkg/mod/github.com/wsvn53/[email protected]/server.go:479 +0x200
Mar 19 19:00:47 Phicomm-N1.lan systemd[1]: clash.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Mar 19 19:00:47 Phicomm-N1.lan systemd[1]: clash.service: Failed with result 'exit-code'.
Mar 19 19:00:50 Phicomm-N1.lan systemd[1]: clash.service: Service RestartSec=3s expired, scheduling restart.
Mar 19 19:00:50 Phicomm-N1.lan systemd[1]: clash.service: Scheduled restart job, restart counter is at 4.
Mar 19 19:00:50 Phicomm-N1.lan systemd[1]: Stopped A rule-based tunnel in Go..
Mar 19 19:00:50 Phicomm-N1.lan systemd[1]: Starting A rule-based tunnel in Go....
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /root/go/pkg/mod/github.com/wsvn53/[email protected]/msg.go:215 +0x34
额,看样子不止这一个地方在写 .Question,你有 panic 前的 dns query 日志吗?
Mar 19 19:00:47 Phicomm-N1.lan clash[4285]: /root/go/pkg/mod/github.com/wsvn53/[email protected]/msg.go:215 +0x34
额,看样子不止这一个地方在写 .Question,你有 panic 前的 dns query 日志吗?
我改了一下代码让DNS请求之前先打印日志,等我跑一会儿看看。
@CyberKoo 求用附件的二进制在你的 N1 跑一下试试,我本地把所有可能对 Question 写操作的都改成了赋值
clash-linux-armv8-dev-dns_fixed_all.zip
@wsvn53
一样崩溃,我跑了个小脚本进行DNS并发请求。
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: panic: runtime error: invalid memory address or nil pointer dereference
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x9 pc=0x12514]
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: goroutine 9697 [running]:
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: strings.HasSuffix(...)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /usr/local/Cellar/go/1.14/libexec/src/strings/strings.go:454
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: strings.TrimSuffix(...)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /usr/local/Cellar/go/1.14/libexec/src/strings/strings.go:916
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: github.com/miekg/dns.IsFqdn(0x0, 0xa, 0x472fa8)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /Users/ethan/Src/dns/defaults.go:276 +0x108
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: github.com/miekg/dns.packDomainName(0x0, 0xa, 0x40009cfe40, 0x35, 0x35, 0xc, 0x0, 0x0, 0x0, 0x3cc360, ...)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /Users/ethan/Src/dns/msg.go:215 +0x34
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: github.com/miekg/dns.(*Question).pack(0x4000a47d00, 0x40009cfe40, 0x35, 0x35, 0xc, 0x0, 0x0, 0x35e300, 0xc, 0x0, ...)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /Users/ethan/Src/dns/msg.go:1084 +0x6c
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: github.com/miekg/dns.(*Msg).packBufferWithCompressionMap(0x4000433d40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4000492380, 0xffff9d7d4560, ...)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /Users/ethan/Src/dns/msg.go:799 +0x280
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: github.com/miekg/dns.(*Msg).PackBuffer(0x4000433d40, 0x0, 0x0, 0x0, 0x20, 0x41d1e0, 0x35e301, 0x4000520200, 0x4000682e08)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /Users/ethan/Src/dns/msg.go:733 +0xf0
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: github.com/miekg/dns.(*Msg).Pack(...)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /Users/ethan/Src/dns/msg.go:721
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: github.com/miekg/dns.(*response).WriteMsg(0x4000246840, 0x4000433d40, 0x0, 0x4000433d40)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /Users/ethan/Src/dns/server.go:671 +0x48
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: github.com/Dreamacro/clash/dns.withResolver.func1(0x52da60, 0x4000246840, 0x4000177290)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /Users/ethan/Src/clash/dns/middleware.go:61 +0x164
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: github.com/Dreamacro/clash/dns.(*Server).ServeDNS(0x4000565ee0, 0x52da60, 0x4000246840, 0x4000177290)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /Users/ethan/Src/clash/dns/server.go:27 +0x70
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: github.com/miekg/dns.(*Server).serveDNS(0x400041d680, 0x40009cc000, 0x1b, 0x200, 0x4000246840)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /Users/ethan/Src/dns/server.go:609 +0x25c
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: github.com/miekg/dns.(*Server).serveUDPPacket(0x400041d680, 0x4000441d70, 0x40009cc000, 0x1b, 0x200, 0x4000128628, 0x4000532760)
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /Users/ethan/Src/dns/server.go:549 +0xa8
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: created by github.com/miekg/dns.(*Server).serveUDP
Mar 19 20:21:22 Phicomm-N1.lan clash[12693]: /Users/ethan/Src/dns/server.go:479 +0x1f8
Mar 19 20:21:22 Phicomm-N1.lan systemd[1]: clash.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Mar 19 20:21:22 Phicomm-N1.lan systemd[1]: clash.service: Failed with result 'exit-code'.
Mar 19 20:21:25 Phicomm-N1.lan systemd[1]: clash.service: Service RestartSec=3s expired, scheduling restart.
Mar 19 20:21:25 Phicomm-N1.lan systemd[1]: clash.service: Scheduled restart job, restart counter is at 1.
Mar 19 20:21:25 Phicomm-N1.lan systemd[1]: Stopped A rule-based tunnel in Go..
Mar 19 20:21:25 Phicomm-N1.lan systemd[1]: Starting A rule-based tunnel in Go....
@CyberKoo 能分享一下你的小脚本 我也写了个但还是很难重现
@CyberKoo 能分享一下你的小脚本 我也写了个但还是很难重现
https://gist.github.com/CyberKoo/3e01be88f627f2e78de13db7717ac33b
需要 dnspython,domains.txt里面我大概放了200个域名
@CyberKoo 能分享一下你的小脚本 我也写了个但还是很难重现
https://gist.github.com/CyberKoo/3e01be88f627f2e78de13db7717ac33b
需要 dnspython,domains.txt里面我大概放了200个域名
感谢这个脚本,已经能复现
The latest release doesn't fix the bug.
OS: Armbian (Debian 10)
Kernel: 5.3.0
Clash version: Clash v0.19.0 linux arm64 Sun Mar 22 09:33:10 UTC 2020
Mar 23 00:47:14 localhost clash[12990]: panic: runtime error: invalid memory address or nil pointer dereference
Mar 23 00:47:14 localhost clash[12990]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x12514]
Mar 23 00:47:14 localhost clash[12990]: goroutine 20209 [running]:
Mar 23 00:47:14 localhost clash[12990]: strings.HasSuffix(...)
Mar 23 00:47:14 localhost clash[12990]: #011/opt/hostedtoolcache/go/1.14.1/x64/src/strings/strings.go:454
Mar 23 00:47:14 localhost clash[12990]: strings.TrimSuffix(...)
Mar 23 00:47:14 localhost clash[12990]: #011/opt/hostedtoolcache/go/1.14.1/x64/src/strings/strings.go:916
Mar 23 00:47:14 localhost clash[12990]: github.com/miekg/dns.IsFqdn(0x0, 0x19, 0x484060)
Mar 23 00:47:14 localhost clash[12990]: #011/home/runner/go/pkg/mod/github.com/miekg/[email protected]/defaults.go:270 +0x108
Mar 23 00:47:14 localhost clash[12990]: github.com/miekg/dns.packDomainName(0x0, 0x19, 0x40000b7f00, 0x7b, 0x7b, 0xc, 0x0, 0x0, 0x0, 0x3dc5c0, ...)
Mar 23 00:47:14 localhost clash[12990]: #011/home/runner/go/pkg/mod/github.com/miekg/[email protected]/msg.go:215 +0x34
Mar 23 00:47:14 localhost clash[12990]: github.com/miekg/dns.(Question).pack(0x4000590d00, 0x40000b7f00, 0x7b, 0x7b, 0xc, 0x0, 0x0, 0x364100, 0xc, 0x0, ...)
Mar 23 00:47:14 localhost clash[12990]: #011/home/runner/go/pkg/mod/github.com/miekg/[email protected]/msg.go:1082 +0x6c
Mar 23 00:47:14 localhost clash[12990]: github.com/miekg/dns.(Msg).packBufferWithCompressionMap(0x4000507d40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, ...)
Mar 23 00:47:14 localhost clash[12990]: #011/home/runner/go/pkg/mod/github.com/miekg/[email protected]/msg.go:800 +0x280
Mar 23 00:47:14 localhost clash[12990]: github.com/miekg/dns.(Msg).PackBuffer(0x4000507d40, 0x0, 0x0, 0x0, 0x19, 0x10001, 0x364220, 0x4000590db0, 0x4000590e08)
Mar 23 00:47:14 localhost clash[12990]: #011/home/runner/go/pkg/mod/github.com/miekg/[email protected]/msg.go:734 +0xf0
Mar 23 00:47:14 localhost clash[12990]: github.com/miekg/dns.(Msg).Pack(...)
Mar 23 00:47:14 localhost clash[12990]: #011/home/runner/go/pkg/mod/github.com/miekg/[email protected]/msg.go:722
Mar 23 00:47:14 localhost clash[12990]: github.com/miekg/dns.(response).WriteMsg(0x40008354a0, 0x4000507d40, 0x1, 0x4000350780)
Mar 23 00:47:14 localhost clash[12990]: #011/home/runner/go/pkg/mod/github.com/miekg/[email protected]/server.go:671 +0x48
Mar 23 00:47:14 localhost clash[12990]: github.com/Dreamacro/clash/dns.withResolver.func1(0x53f220, 0x40008354a0, 0x400058d3b0)
Mar 23 00:47:14 localhost clash[12990]: #011/home/runner/work/clash/clash/dns/middleware.go:61 +0x18c
Mar 23 00:47:14 localhost clash[12990]: github.com/Dreamacro/clash/dns.(Server).ServeDNS(0x40003cbb60, 0x53f220, 0x40008354a0, 0x400058d3b0)
Mar 23 00:47:14 localhost clash[12990]: #011/home/runner/work/clash/clash/dns/server.go:27 +0x70
Mar 23 00:47:14 localhost clash[12990]: github.com/miekg/dns.(Server).serveDNS(0x4000356240, 0x40005caa00, 0x2a, 0x200, 0x40008354a0)
Mar 23 00:47:14 localhost clash[12990]: #011/home/runner/go/pkg/mod/github.com/miekg/[email protected]/server.go:609 +0x25c
Mar 23 00:47:14 localhost clash[12990]: github.com/miekg/dns.(Server).serveUDPPacket(0x4000356240, 0x40001aa024, 0x40005caa00, 0x2a, 0x200, 0x40000bc300, 0x400038b640)
Mar 23 00:47:14 localhost clash[12990]: #011/home/runner/go/pkg/mod/github.com/miekg/[email protected]/server.go:549 +0xa8
Mar 23 00:47:14 localhost clash[12990]: created by github.com/miekg/dns.(*Server).serveUDP
Mar 23 00:47:14 localhost clash[12990]: #011/home/runner/go/pkg/mod/github.com/miekg/[email protected]/server.go:479 +0x1f8
Mar 23 00:47:14 localhost systemd[1]: clash.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Mar 23 00:47:14 localhost systemd[1]: clash.service: Failed with result 'exit-code'.
@wsvn53 试试这个 patch
-ret, err, _ := r.group.Do(q.String(), func() (interface{}, error) {
+ret, err, shared := r.group.Do(q.String(), func() (interface{}, error) {
isIPReq := isIPRequest(q)
if isIPReq {
return r.fallbackExchange(m)
}
return r.batchExchange(r.main, m)
})
if err == nil {
msg = ret.(*D.Msg)
+ if shared {
+ msg = msg.Copy()
+ }
}
@wsvn53 试试这个 patch
-ret, err, _ := r.group.Do(q.String(), func() (interface{}, error) { +ret, err, shared := r.group.Do(q.String(), func() (interface{}, error) { isIPReq := isIPRequest(q) if isIPReq { return r.fallbackExchange(m) } return r.batchExchange(r.main, m) }) if err == nil { msg = ret.(*D.Msg) + if shared { + msg = msg.Copy() + } }
OK, 正在跑了
@Dreamacro 跑了3个小时目前还没挂,没这个 patch 前一小时得挂个一两次,再跑几个小时我把 patch 移除掉再确认一下
@Dreamacro 基本可以确定,这个改动修复了之前的 issue 中的 panic,反反复复跑了近 10 个小时没有任何 panic,👍👍
dev 分支修复了