sing-box
sing-box copied to clipboard
Some config file may cause crashes
Operating system
Windows
System version
Windows 11 Enterprise 23H2 (22631.3593)
Installation type
Original sing-box Command Line
If you are using a graphical client, please provide the version of the client.
No response
Version
sing-box version 1.9.0
Environment: go1.22.3 windows/amd64
Tags: with_gvisor,with_quic,with_dhcp,with_wireguard,with_ech,with_utls,with_reality_server,with_acme,with_clash_api
Revision: 5ff7006326e8a876d33d92b26ebd2671cdd48b9f
CGO: disabled
Description
Some configuration files may cause crashes. I've provided an example configuration file below.
I've tracked down the bug and it was introduced between 1.8.0-beta.4 and 1.8.0-beta.6. In 1.8.0-beta.4 the following configuration file works flawlessly, and starting from 1.8.0-beta.6 it no longer works.
This bug also applies to official iOS (1.9.0) and Android (1.10.0-alpha.2) clients.
Reproduction
In elevated command prompt, run:
sing-box.exe run -c .\config.json
The problematic configuration file:
{
"log": {
"disabled": false,
"level": "trace",
"timestamp": false
},
"dns": {
"servers": [
{
"tag": "dns-proxy",
"address": "udp://1.0.0.1",
"detour": "bbbbb"
},
{
"tag": "dns-direct",
"address": "https://dns.alidns.com/dns-query",
"address_resolver": "dns-resolver",
"detour": "aaaaa"
},
{
"tag": "dns-resolver",
"address": "74.82.42.42",
"detour": "direct"
}
],
"rules": [
{
"outbound": "any",
"server": "dns-direct"
},
{
"rule_set": [
"geosite-cn"
],
"server": "dns-direct"
}
],
"final": "dns-proxy",
"strategy": "prefer_ipv4",
"disable_cache": false,
"disable_expire": false,
"independent_cache": true,
"reverse_mapping": false
},
"inbounds": [
{
"type": "tun",
"tag": "tun-in",
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126",
"auto_route": true,
"strict_route": true,
"sniff": true,
"endpoint_independent_nat": false,
"stack": "system"
}
],
"outbounds": [
{
"type": "trojan",
"tag": "trojan-11111",
"server": "cdnjs.cloudflare.com",
"server_port": 233,
"password": "1111111111111111111111111111111",
"tls": {
"enabled": true
},
"tcp_fast_open": true
},
{
"type": "trojan",
"tag": "trojan-22222",
"server": "cdnjs.cloudflare.com",
"server_port": 233,
"password": "1111111111111111111111111111111",
"tls": {
"enabled": true
},
"tcp_fast_open": true
},
{
"type": "trojan",
"tag": "trojan-33333",
"server": "cdnjs.cloudflare.com",
"server_port": 233,
"password": "1111111111111111111111111111111",
"tls": {
"enabled": true
},
"tcp_fast_open": true
},
{
"type": "trojan",
"tag": "trojan-44444",
"server": "cdnjs.cloudflare.com",
"server_port": 233,
"password": "1111111111111111111111111111111",
"tls": {
"enabled": true
},
"multiplex": {
"enabled": true
},
"tcp_fast_open": true
},
{
"type": "trojan",
"tag": "trojan-ws-11111",
"server": "aaaaaaaaaaaaaaa.porkbun.com",
"server_port": 233,
"password": "1111111111111111111111111111111",
"tls": {
"enabled": true
},
"multiplex": {
"enabled": true
},
"transport": {
"type": "ws",
"path": "/111111111111111111111111111111111111"
},
"tcp_fast_open": true
},
{
"type": "trojan",
"tag": "trojan-ws-22222",
"server": "aaaaaaaaaaaaaaa.porkbun.com",
"server_port": 233,
"password": "1111111111111111111111111111111",
"tls": {
"enabled": true
},
"multiplex": {
"enabled": true
},
"transport": {
"type": "ws",
"path": "/111111111111111111111111111111111111"
},
"tcp_fast_open": true
},
{
"type": "trojan",
"tag": "trojan-ws-33333",
"server": "aaaaaaaaaaaaaaaaaaa.porkbun.com",
"server_port": 233,
"password": "1111111111111111111111111111111",
"tls": {
"enabled": true
},
"multiplex": {
"enabled": true
},
"transport": {
"type": "ws",
"path": "/111111111111111111111111111111111111"
},
"tcp_fast_open": true
},
{
"type": "wireguard",
"tag": "wg-1111",
"local_address": [
"192.168.0.1/32",
"2001:1111:111:1111:111:1111:1111:111/128"
],
"private_key": "kBYbjzUqq0dOxNxLT1wTO7oQ7rQuA6URX08hewaV2U8=",
"peers": [
{
"server": "aaaaaaaaaaaaaaa.porkbun.com",
"server_port": 2333,
"public_key": "kTsgZURPG1dkirckXUTFVNcM/tW0iXiJJa+yLfO8qDQ=",
"allowed_ips": [
"0.0.0.0/0",
"::/0"
],
"reserved": [
0,
0,
0
]
}
],
"mtu": 1111
},
{
"type": "shadowsocks",
"tag": "ss-11111",
"server": "aaaaaaaaaa.porkbun.com",
"server_port": 23333,
"method": "aes-256-ctr",
"password": "1111111111111111111111111111111",
"tcp_fast_open": true
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "dns",
"tag": "dns-out"
},
{
"type": "urltest",
"tag": "urltest",
"outbounds": [
"trojan-11111",
"trojan-22222",
"trojan-33333",
"trojan-44444",
"trojan-ws-11111",
"trojan-ws-22222",
"trojan-ws-33333",
"wg-1111",
"ss-11111"
],
"url": "https://www.gstatic.com/generate_204",
"interval": "1m",
"tolerance": 50,
"interrupt_exist_connections": false
},
{
"type": "selector",
"tag": "aaaaa",
"outbounds": [
"urltest",
"trojan-11111",
"trojan-22222",
"trojan-33333",
"trojan-44444",
"trojan-ws-11111",
"trojan-ws-22222",
"trojan-ws-33333",
"wg-1111",
"ss-11111",
"direct"
],
"default": "direct",
"interrupt_exist_connections": false
},
{
"type": "selector",
"tag": "bbbbb",
"outbounds": [
"urltest",
"trojan-11111",
"trojan-22222",
"trojan-33333",
"trojan-44444",
"trojan-ws-11111",
"trojan-ws-22222",
"trojan-ws-33333",
"wg-1111",
"ss-11111",
"direct"
],
"default": "urltest",
"interrupt_exist_connections": false
}
],
"route": {
"rule_set": [
{
"tag": "geosite-cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs",
"download_detour": "direct"
},
{
"tag": "geoip-cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs",
"download_detour": "direct"
}
],
"rules": [
{
"type": "logical",
"mode": "or",
"rules": [
{
"protocol": "dns"
},
{
"port": 53
}
],
"outbound": "dns-out"
},
{
"ip_is_private": true,
"outbound": "direct"
},
{
"rule_set": [
"geosite-cn",
"geoip-cn"
],
"outbound": "aaaaa"
}
],
"final": "bbbbb",
"auto_detect_interface": true,
"override_android_vpn": false
},
"experimental": {
"cache_file": {
"enabled": true
}
}
}
Logs
INFO[0000] router: updated default interface Wi-Fi, index 22
DEBUG[0000] dns: lookup domain aaaaaaaaaaaaaaa.porkbun.com
DEBUG[0000] dns: match[0] outbound=any => dns-direct
INFO[0000] outbound/direct[direct]: outbound packet connection to 74.82.42.42:53
DEBUG[0000] dns: exchanged dns.alidns.com NOERROR 3297
DEBUG[0000] dns: exchanged dns.alidns.com NOERROR 3297
INFO[0000] dns: exchanged dns.alidns.com A dns.alidns.com. 3297 IN A 223.5.5.5
INFO[0000] dns: exchanged dns.alidns.com A dns.alidns.com. 3297 IN A 223.6.6.6
INFO[0000] dns: exchanged dns.alidns.com A dns.alidns.com. 3297 IN A 223.5.5.5
INFO[0000] dns: exchanged dns.alidns.com A dns.alidns.com. 3297 IN A 223.6.6.6
DEBUG[0000] dns: exchanged dns.alidns.com NOERROR 1758
DEBUG[0000] dns: exchanged dns.alidns.com NOERROR 1758
INFO[0000] dns: exchanged dns.alidns.com AAAA dns.alidns.com. 1758 IN AAAA 2400:3200::1
INFO[0000] dns: exchanged dns.alidns.com AAAA dns.alidns.com. 1758 IN AAAA 2400:3200:baba::1
INFO[0000] dns: exchanged dns.alidns.com AAAA dns.alidns.com. 1758 IN AAAA 2400:3200::1
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x19cb825]
goroutine 31 [running]:
github.com/sagernet/sing-box/outbound.(*Selector).DialContext(0xc0002e01a0, {0x201c620, 0xc0002de5a0}, {0x1e0f7a3?, 0xc0000d2120?}, {{{0x0, 0xffffdf050505}, 0xc0000080d8}, 0x1bb, {0x0, ...}})
github.com/sagernet/sing-box/outbound/selector.go:130 +0x45
github.com/sagernet/sing-box/common/dialer.(*DetourDialer).DialContext(0x0?, {0x201c620, 0xc0002de5a0}, {0x1e0f7a3, 0x3}, {{{0x0, 0xffffdf050505}, 0xc0000080d8}, 0x1bb, {0x0, ...}})
github.com/sagernet/sing-box/common/dialer/detour.go:47 +0x8f
github.com/sagernet/sing/common/network.DialSerial({0x201c620, 0xc0002de5a0}, {0x2012548, 0xc0000a1ea0}, {0x1e0f7a3, 0x3}, {{{0x0, 0x0}, 0x0}, 0x1bb, ...}, ...)
github.com/sagernet/[email protected]/common/network/multi.go:24 +0x1ab
github.com/sagernet/sing/common/network.DialParallel.func3({0x201c620, 0xc0002de5a0?}, 0x1)
github.com/sagernet/[email protected]/common/network/multi.go:88 +0xc9
created by github.com/sagernet/sing/common/network.DialParallel in goroutine 34
github.com/sagernet/[email protected]/common/network/multi.go:100 +0x665
Supporter
- [ ] I am a sponsor
Integrity requirements
- [X] I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
- [ ] I confirm that I have provided the server and client configuration files and process that can be reproduced locally, instead of a complicated client configuration file that has been stripped of sensitive data.
- [X] I confirm that I have provided the simplest configuration that can be used to reproduce the error I reported, instead of depending on remote servers, TUN, graphical interface clients, or other closed-source software.
- [X] I confirm that I have provided the complete configuration files and logs, rather than just providing parts I think are useful out of confidence in my own intelligence.