SagerNet / sing-box

The universal proxy platform
https://sing-box.sagernet.org/
Other
20.29k stars 2.42k forks source link

shadowsocks mux报错 #2050

Closed nightyin closed 3 months ago

nightyin commented 3 months ago

操作系统

Linux

系统版本

ubuntu 22

安装类型

sing-box 原始命令行程序

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

No response

版本

sing-box version v1.10.0-beta.2

Environment: go1.23.0 linux/amd64

描述

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x1216472]

goroutine 253 [running]: github.com/sagernet/sing-box/outbound.(loopBackDetector).NewConn(0xc0001f3180, {0x0, 0x0}) /app/outbound/direct_loopback_detect.go:30 +0x32 github.com/sagernet/sing-box/outbound.(Direct).DialContext(0xc000299ad0, {0x1930e58?, 0xc00057f0b0?}, {0x16e56dd, 0x3}, {{{0x0, 0x0}, {0x0}}, 0x1bb, {0xc00056af80, ...}}) /app/outbound/direct.go:97 +0x4f5 github.com/sagernet/sing-box/outbound.NewConnection({, }, {, }, {, }, {{0xc0001dc4b4, 0x2}, {0x16ee953, 0xb}, ...}) /app/outbound/default.go:67 +0x192 github.com/sagernet/sing-box/outbound.(Direct).NewConnection(, {, }, {, _}, {{0xc0001dc4b4, 0x2}, {0x16ee953, 0xb}, 0x0, ...}) /app/outbound/direct.go:162 +0x247 github.com/sagernet/sing-box/route.(Router).RouteConnection(, {, }, {, }, {{0xc0001dc4b4, 0x2}, {0x16ee953, 0xb}, 0x0, ...}) /app/route/router.go:926 +0x17f3 github.com/sagernet/sing-box/common/uot.(*Router).RouteConnection(, {, }, {, }, {{0xc0001dc4b4, 0x2}, {0x16ee953, 0xb}, 0x0, ...}) /app/common/uot/router.go:48 +0x15b github.com/sagernet/sing-box/adapter.(routeContextHandlerWrapper).NewConnection(0xc0001e0d60, {0x1930e58, 0xc00057ef30}, {0x193d8d0, 0xc000454f18}, {{0x0, 0x0}, {{{0x0, 0xffffac1e0002}, {0xc000010450}}, ...}, ...}) /app/adapter/conn_router.go:88 +0x335 github.com/sagernet/sing-mux.(Service).newConnection(0xc0001f30e0, {0x1930e58, 0xc00057ef30}, {0x193adf0, 0xc0002be540}, {0x193dbe8, 0xc00003fdc0}, {{0x0, 0x0}, {{{0x0, ...}, ...}, ...}, ...}) /go/pkg/mod/github.com/sagernet/sing-mux@v0.2.0/server.go:132 +0xd9f github.com/sagernet/sing-mux.(Service).NewConnection.func1.1() /go/pkg/mod/github.com/sagernet/sing-mux@v0.2.0/server.go:74 +0x7e created by github.com/sagernet/sing-mux.(Service).NewConnection.func1 in goroutine 220 /go/pkg/mod/github.com/sagernet/sing-mux@v0.2.0/server.go:73 +0xde

重现方式

复现方式 开启shadowsocks连接复用

nginx 配置stream分流 第一种map map $remote_addr $stream_map { xxxx singbox-2; xxxx singbox-1; default https_backend; } 第二种2个请求放在一个上面 map $remote_addr $stream_map { xxxx singbox; default https_backend; } server { listen 443 reuseport so_keepalive=on fastopen=500; proxy_pass $stream_map; ssl_preread on; } 三台服务器 a b c a访问x网站 请求b c访问x网站 请求b

tuic也有这种情况 sing-tuic报错

日志

No response

支持我们

完整性要求

nightyin commented 3 months ago

在报错前有个dns error

+0800 2024-08-20 20:05:21 INFO [631858852 3ms] dns: exchanged notifications.netflix.com SOA netflix.com. 147 IN SOA ns-81.awsdns-10.com. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 1800 +0800 2024-08-20 20:05:21 ERROR [631858852 3ms] dns: lookup failed for notifications.netflix.com: empty result +0800 2024-08-20 20:05:21 INFO [3999304764 0ms] inbound/shadowsocks[sg]: inbound multiplex connection to notifications.netflix.com:443 +0800 2024-08-20 20:05:21 INFO [3999304764 0ms] outbound/direct[direct]: outbound connection to notifications.netflix.com:443 panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x1216472]

goroutine 635 [running]: github.com/sagernet/sing-box/outbound.(loopBackDetector).NewConn(0xc0001816d0, {0x0, 0x0}) /app/outbound/direct_loopback_detect.go:30 +0x32 github.com/sagernet/sing-box/outbound.(Direct).DialContext(0xc0002a11e0, {0x1930e58?, 0xc0002efad0?}, {0x16e56dd, 0x3}, {{{0x0, 0x0}, {0x0}}, 0x1bb, {0xc0000d0a20, ...}}) /app/outbound/direct.go:97 +0x4f5 github.com/sagernet/sing-box/outbound.NewConnection({, }, {, }, {, }, {{0xc00027e024, 0x2}, {0x16ee953, 0xb}, ...}) /app/outbound/default.go:67 +0x192 github.com/sagernet/sing-box/outbound.(Direct).NewConnection(, {, }, {, _}, {{0xc00027e024, 0x2}, {0x16ee953, 0xb}, 0x0, ...}) /app/outbound/direct.go:162 +0x247 github.com/sagernet/sing-box/route.(Router).RouteConnection(, {, }, {, }, {{0xc00027e024, 0x2}, {0x16ee953, 0xb}, 0x0, ...}) /app/route/router.go:926 +0x17f3 github.com/sagernet/sing-box/common/uot.(*Router).RouteConnection(, {, }, {, }, {{0xc00027e024, 0x2}, {0x16ee953, 0xb}, 0x0, ...}) /app/common/uot/router.go:48 +0x15b github.com/sagernet/sing-box/adapter.(routeContextHandlerWrapper).NewConnection(0xc00014fea0, {0x1930e58, 0xc0002ef920}, {0x193d8d0, 0xc0000113e0}, {{0x0, 0x0}, {{{0x0, 0xffffac1e0002}, {0xc000114438}}, ...}, ...}) /app/adapter/conn_router.go:88 +0x335 github.com/sagernet/sing-mux.(Service).newConnection(0xc000181630, {0x1930e58, 0xc0002ef920}, {0x193adf0, 0xc0002ee840}, {0x193dbe8, 0xc000461600}, {{0x0, 0x0}, {{{0x0, ...}, ...}, ...}, ...}) /go/pkg/mod/github.com/sagernet/sing-mux@v0.2.0/server.go:132 +0xd9f github.com/sagernet/sing-mux.(Service).NewConnection.func1.1() /go/pkg/mod/github.com/sagernet/sing-mux@v0.2.0/server.go:74 +0x7e created by github.com/sagernet/sing-mux.(Service).NewConnection.func1 in goroutine 597 /go/pkg/mod/github.com/sagernet/sing-mux@v0.2.0/server.go:73 +0xde

nightyin commented 3 months ago

暂时先把notifications.netflix.com这个给reject了 这个dns解析后只有ipv6 但是singbox这设置了ipv4 only导致的

nekohasekai commented 3 months ago

试试 1.10.0-beta.3

nightyin commented 3 months ago

试试 1.10.0-beta.3


+0800 2024-08-20 23:00:45 INFO [4065118907 0ms] inbound/shadowsocks[sg]: inbound multiplex connection to notifications.netflix.com:443
+0800 2024-08-20 23:00:45 INFO [4065118907 0ms] outbound/direct[direct]: outbound connection to notifications.netflix.com:443
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x1216452]

goroutine 1842 [running]:
github.com/sagernet/sing-box/outbound.(*loopBackDetector).NewConn(0xc000097590, {0x0, 0x0})
    /app/outbound/direct_loopback_detect.go:30 +0x32
github.com/sagernet/sing-box/outbound.(*Direct).DialContext(0xc000271380, {0x1930eb8?, 0xc00057bda0?}, {0x16e56dd, 0x3}, {{{0x0, 0x0}, {0x0}}, 0x1bb, {0xc000265a40, ...}})
    /app/outbound/direct.go:97 +0x4f5
github.com/sagernet/sing-box/outbound.NewConnection({_, _}, {_, _}, {_, _}, {{0xc000250044, 0x2}, {0x16ee953, 0xb}, ...})
    /app/outbound/default.go:67 +0x192
github.com/sagernet/sing-box/outbound.(*Direct).NewConnection(_, {_, _}, {_, _}, {{0xc000250044, 0x2}, {0x16ee953, 0xb}, 0x0, ...})
    /app/outbound/direct.go:162 +0x247
github.com/sagernet/sing-box/route.(*Router).RouteConnection(_, {_, _}, {_, _}, {{0xc000250044, 0x2}, {0x16ee953, 0xb}, 0x0, ...})
    /app/route/router.go:927 +0x1813
github.com/sagernet/sing-box/common/uot.(*Router).RouteConnection(_, {_, _}, {_, _}, {{0xc000250044, 0x2}, {0x16ee953, 0xb}, 0x0, ...})
    /app/common/uot/router.go:48 +0x15b
github.com/sagernet/sing-box/adapter.(*routeContextHandlerWrapper).NewConnection(0xc000089dc0, {0x1930eb8, 0xc00057b9e0}, {0x193d930, 0xc000000a08}, {{0x0, 0x0}, {{{0x0, 0xffffac1e0002}, {0xc000010450}}, ...}, ...})
    /app/adapter/conn_router.go:88 +0x335
github.com/sagernet/sing-mux.(*Service).newConnection(0xc000097540, {0x1930eb8, 0xc00057b9e0}, {0x193ae50, 0xc0001318c0}, {0x193dc48, 0xc0009cdd40}, {{0x0, 0x0}, {{{0x0, ...}, ...}, ...}, ...})
    /go/pkg/mod/github.com/sagernet/sing-mux@v0.2.0/server.go:132 +0xd9f
github.com/sagernet/sing-mux.(*Service).NewConnection.func1.1()
    /go/pkg/mod/github.com/sagernet/sing-mux@v0.2.0/server.go:74 +0x7e
created by github.com/sagernet/sing-mux.(*Service).NewConnection.func1 in goroutine 755
    /go/pkg/mod/github.com/sagernet/sing-mux@v0.2.0/server.go:73 +0xde``` 
还是存在 但是这次不是在dns error后panic
``` +0800 2024-08-20 22:59:59 INFO [4062053432 18ms] dns: exchanged notifications.netflix.com SOA netflix.com. 496 IN SOA ns-81.awsdns-10.com. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 1800
+0800 2024-08-20 22:59:59 ERROR [4062053432 18ms] dns: lookup failed for notifications.netflix.com: empty result
+0800 2024-08-20 23:00:04 INFO [1555934724 0ms] inbound/shadowsocks[sg]: inbound connection from 172.30.0.2:52118
+0800 2024-08-20 23:00:04 INFO [3283021188 0ms] inbound/shadowsocks[sg]: inbound connection to sp.mux.sing-box.arpa:444
+0800 2024-08-20 23:00:04 INFO [1164022294 0ms] inbound/shadowsocks[sg]: inbound multiplex connection to www.netflix.com:443
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: exchanged www.netflix.com CNAME www.netflix.com. 29 IN CNAME www.dradis.netflix.com.
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: exchanged www.netflix.com CNAME www.dradis.netflix.com. 29 IN CNAME www.us-west-2.internal.dradis.netflix.com.
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: exchanged www.netflix.com CNAME www.us-west-2.internal.dradis.netflix.com. 29 IN CNAME apiproxy-website-nlb-prod-1-bcf28d21f4bbcf2c.elb.us-west-2.amazonaws.com.
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: exchanged www.netflix.com A apiproxy-website-nlb-prod-1-bcf28d21f4bbcf2c.elb.us-west-2.amazonaws.com. 29 IN A 44.242.13.161
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: exchanged www.netflix.com A apiproxy-website-nlb-prod-1-bcf28d21f4bbcf2c.elb.us-west-2.amazonaws.com. 29 IN A 44.240.158.19
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: exchanged www.netflix.com A apiproxy-website-nlb-prod-1-bcf28d21f4bbcf2c.elb.us-west-2.amazonaws.com. 29 IN A 52.38.7.83
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: lookup succeed for www.netflix.com: 44.242.13.161 44.240.158.19 52.38.7.83
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] outbound/direct[direct]: outbound connection to www.netflix.com:443
+0800 2024-08-20 23:00:04 INFO [4271820479 0ms] inbound/shadowsocks[sg]: inbound multiplex connection to www.netflix.com:443
+0800 2024-08-20 23:00:04 INFO [4271820479 0ms] outbound/direct[direct]: outbound connection to www.netflix.com:443
+0800 2024-08-20 23:00:04 INFO [1747122419 0ms] inbound/shadowsocks[sg]: inbound connection from 172.30.0.2:52130
+0800 2024-08-20 23:00:04 INFO [2387287899 0ms] inbound/shadowsocks[sg]: inbound connection to sp.mux.sing-box.arpa:444`` 
nightyin commented 3 months ago

试试 1.10.0-beta.3

+0800 2024-08-20 23:00:45 INFO [4065118907 0ms] inbound/shadowsocks[sg]: inbound multiplex connection to notifications.netflix.com:443
+0800 2024-08-20 23:00:45 INFO [4065118907 0ms] outbound/direct[direct]: outbound connection to notifications.netflix.com:443
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x1216452]

goroutine 1842 [running]:
github.com/sagernet/sing-box/outbound.(*loopBackDetector).NewConn(0xc000097590, {0x0, 0x0})
  /app/outbound/direct_loopback_detect.go:30 +0x32
github.com/sagernet/sing-box/outbound.(*Direct).DialContext(0xc000271380, {0x1930eb8?, 0xc00057bda0?}, {0x16e56dd, 0x3}, {{{0x0, 0x0}, {0x0}}, 0x1bb, {0xc000265a40, ...}})
  /app/outbound/direct.go:97 +0x4f5
github.com/sagernet/sing-box/outbound.NewConnection({_, _}, {_, _}, {_, _}, {{0xc000250044, 0x2}, {0x16ee953, 0xb}, ...})
  /app/outbound/default.go:67 +0x192
github.com/sagernet/sing-box/outbound.(*Direct).NewConnection(_, {_, _}, {_, _}, {{0xc000250044, 0x2}, {0x16ee953, 0xb}, 0x0, ...})
  /app/outbound/direct.go:162 +0x247
github.com/sagernet/sing-box/route.(*Router).RouteConnection(_, {_, _}, {_, _}, {{0xc000250044, 0x2}, {0x16ee953, 0xb}, 0x0, ...})
  /app/route/router.go:927 +0x1813
github.com/sagernet/sing-box/common/uot.(*Router).RouteConnection(_, {_, _}, {_, _}, {{0xc000250044, 0x2}, {0x16ee953, 0xb}, 0x0, ...})
  /app/common/uot/router.go:48 +0x15b
github.com/sagernet/sing-box/adapter.(*routeContextHandlerWrapper).NewConnection(0xc000089dc0, {0x1930eb8, 0xc00057b9e0}, {0x193d930, 0xc000000a08}, {{0x0, 0x0}, {{{0x0, 0xffffac1e0002}, {0xc000010450}}, ...}, ...})
  /app/adapter/conn_router.go:88 +0x335
github.com/sagernet/sing-mux.(*Service).newConnection(0xc000097540, {0x1930eb8, 0xc00057b9e0}, {0x193ae50, 0xc0001318c0}, {0x193dc48, 0xc0009cdd40}, {{0x0, 0x0}, {{{0x0, ...}, ...}, ...}, ...})
  /go/pkg/mod/github.com/sagernet/sing-mux@v0.2.0/server.go:132 +0xd9f
github.com/sagernet/sing-mux.(*Service).NewConnection.func1.1()
  /go/pkg/mod/github.com/sagernet/sing-mux@v0.2.0/server.go:74 +0x7e
created by github.com/sagernet/sing-mux.(*Service).NewConnection.func1 in goroutine 755
  /go/pkg/mod/github.com/sagernet/sing-mux@v0.2.0/server.go:73 +0xde``` 
还是存在 但是这次不是在dns error后panic
``` +0800 2024-08-20 22:59:59 INFO [4062053432 18ms] dns: exchanged notifications.netflix.com SOA netflix.com. 496 IN SOA ns-81.awsdns-10.com. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 1800
+0800 2024-08-20 22:59:59 ERROR [4062053432 18ms] dns: lookup failed for notifications.netflix.com: empty result
+0800 2024-08-20 23:00:04 INFO [1555934724 0ms] inbound/shadowsocks[sg]: inbound connection from 172.30.0.2:52118
+0800 2024-08-20 23:00:04 INFO [3283021188 0ms] inbound/shadowsocks[sg]: inbound connection to sp.mux.sing-box.arpa:444
+0800 2024-08-20 23:00:04 INFO [1164022294 0ms] inbound/shadowsocks[sg]: inbound multiplex connection to www.netflix.com:443
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: exchanged www.netflix.com CNAME www.netflix.com. 29 IN CNAME www.dradis.netflix.com.
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: exchanged www.netflix.com CNAME www.dradis.netflix.com. 29 IN CNAME www.us-west-2.internal.dradis.netflix.com.
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: exchanged www.netflix.com CNAME www.us-west-2.internal.dradis.netflix.com. 29 IN CNAME apiproxy-website-nlb-prod-1-bcf28d21f4bbcf2c.elb.us-west-2.amazonaws.com.
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: exchanged www.netflix.com A apiproxy-website-nlb-prod-1-bcf28d21f4bbcf2c.elb.us-west-2.amazonaws.com. 29 IN A 44.242.13.161
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: exchanged www.netflix.com A apiproxy-website-nlb-prod-1-bcf28d21f4bbcf2c.elb.us-west-2.amazonaws.com. 29 IN A 44.240.158.19
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: exchanged www.netflix.com A apiproxy-website-nlb-prod-1-bcf28d21f4bbcf2c.elb.us-west-2.amazonaws.com. 29 IN A 52.38.7.83
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] dns: lookup succeed for www.netflix.com: 44.242.13.161 44.240.158.19 52.38.7.83
+0800 2024-08-20 23:00:04 INFO [1164022294 3ms] outbound/direct[direct]: outbound connection to www.netflix.com:443
+0800 2024-08-20 23:00:04 INFO [4271820479 0ms] inbound/shadowsocks[sg]: inbound multiplex connection to www.netflix.com:443
+0800 2024-08-20 23:00:04 INFO [4271820479 0ms] outbound/direct[direct]: outbound connection to www.netflix.com:443
+0800 2024-08-20 23:00:04 INFO [1747122419 0ms] inbound/shadowsocks[sg]: inbound connection from 172.30.0.2:52130
+0800 2024-08-20 23:00:04 INFO [2387287899 0ms] inbound/shadowsocks[sg]: inbound connection to sp.mux.sing-box.arpa:444`` 

在第一次连接后 关闭页面 重新打开 出现的panic 看着像cache的问题?

nekohasekai commented 3 months ago

试试 https://github.com/SagerNet/sing-box/commit/42552af8a20ad9ca6023d6dc209df19263c3b00a

nightyin commented 3 months ago

l有个问题想问下,linux中h2mux可以用的情况下,smux和yamux都通不了是什么情况?

nightyin commented 3 months ago

试试 42552af

确认问题已修复