sing-box icon indicating copy to clipboard operation
sing-box copied to clipboard

Panic after sing-box running several hours

Open amirhosss opened this issue 1 year ago • 6 comments

Operating system

Linux

System version

Ubuntu 22.04.3 LTS

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-rc.15 and sing-box version 1.8.13

Description

Hi After several hours, suddenly sing-box crashes and panic happens. I tested multiple times with different multiplex protocol such as yamux and smux, but the problem still exists.

Reproduction

Client (ss-out) > Server_1 (ss-in and vless-out) > Server_2 (vless_in) The panic happens in Server_1

Server_1 Config:

{
   "log":{
    "disabled": false,
    "level": "error",
    "output": "#some_output",
    "timestamp": true
   },
   "dns": {
       "servers": [
	    {
		"tag": "tag1",
		"address": "tcp://#dns_server",
		"strategy": "ipv4_only"
	    },
            {
                "tag": "tag-2",
                "address": "tcp://#dns_server",
                "strategy": "ipv4_only"
            }
	]
   },
   "route": {
       "rules": [
           {
	       "rule_set": "#some_geoip",
	       "outbound": "direct-out"
	   }
       ],
       "rule_set": [
	      {
	        "tag": "#some_geoip",
	        "type": "remote",
	        "format": "binary",
	        "url": "#URL",
	        "download_detour": "direct-out"
	      }
       ]
   },
   "inbounds":[
     {
	  "type": "shadowsocks",
  	  "tag": "SS-In",

          "listen": "::",
          "listen_port": 443,
          "sniff": false,
  	  "sniff_override_destination": false,
          "domain_strategy": "ipv4_only",

	  "method": "2022-blake3-chacha20-poly1305",
	  "password": "#PASSWORD",

	  "multiplex": {
	   "enabled": true,
	   "padding": false
	  }
     }
   ],
   "outbounds":[
      {
	    "type": "vless",
            "tag": "vless-out",

            "server": "#IP",
            "server_port": 443,
            "uuid": "#UUID",
            "tls": {
                "enabled": true,
                "server_name": "#SERVER_NAME",
                "insecure": false,
                "utls": {
                  "enabled": true,
                  "fingerprint": "firefox"
                },
		"ech": {
		  "enabled": true,
		  "pq_signature_schemes_enabled": true,
		  "dynamic_record_sizing_disabled": false,
		  "config_path": "#PATH"
		}
	    },
	   "multiplex": {
	       "enabled": true,
	       "protocol": "smux",
	       "max_streams": 4,
	       "padding": false
	   }
      },
      {
	  "type": "direct",
	  "tag": "direct-out",
	  "domain_strategy": "ipv4_only"
      },
      {
          "type": "block",
          "tag": "block"
      }
   ]
}

Logs

08:31:57  sing-box[31668]: panic: runtime error: invalid memory address or nil pointer dereference
08:31:57  sing-box[31668]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xe522f7]
08:31:57  sing-box[31668]: goroutine 26653 [running]:
08:31:57  sing-box[31668]: github.com/sagernet/smux.(*Stream).tryRead(0x4495f9?, {0xc000890078?, 0x10?, 0xc000d42a18?})
08:31:57  sing-box[31668]:         github.com/sagernet/[email protected]/stream.go:84 +0x17
08:31:57  sing-box[31668]: github.com/sagernet/smux.(*Stream).Read(0x0, {0xc000890078, 0x2, 0x2})
08:31:57  sing-box[31668]:         github.com/sagernet/[email protected]/stream.go:71 +0x45
08:31:57  sing-box[31668]: github.com/sagernet/sing-mux.(*wrapStream).Read(0x0?, {0xc000890078?, 0xc000d42a40?, 0x4573e9?})
08:31:57  sing-box[31668]:         github.com/sagernet/[email protected]/error.go:15 +0x22
08:31:57  sing-box[31668]: io.ReadAtLeast({0x7f4befff6f18, 0xc000fd80f0}, {0xc000890078, 0x2, 0x2}, 0x2)
08:31:57  sing-box[31668]:         io/io.go:335 +0x90
08:31:57  sing-box[31668]: io.ReadFull(...)
08:31:57  sing-box[31668]:         io/io.go:354
08:31:57  sing-box[31668]: encoding/binary.Read({0x7f4befff6f18, 0xc000fd80f0}, {0x1693810, 0x20c9760}, {0x11ea740, 0xc000d42bee})
08:31:57  sing-box[31668]:         encoding/binary/binary.go:241 +0xb4
08:31:57  sing-box[31668]: github.com/sagernet/sing-mux.ReadStreamRequest({0x7f4befff6f18, 0xc000fd80f0})
08:31:57  sing-box[31668]:         github.com/sagernet/[email protected]/protocol.go:119 +0x50
08:31:57  sing-box[31668]: github.com/sagernet/sing-mux.(*Service).newConnection(0xc00007aaa0, {0x168cfc8, 0xc000986240}, {0x1695cd0, 0xc0009c8000}, {0x1698a58, 0x0}, {{0x0, 0x0}, {{{0x0, ...}, ...}, ...}, ...})
08:31:57  sing-box[31668]:         github.com/sagernet/[email protected]/server.go:89 +0x117
08:31:57  sing-box[31668]: github.com/sagernet/sing-mux.(*Service).NewConnection.func1.1()
08:31:57  sing-box[31668]:         github.com/sagernet/[email protected]/server.go:74 +0x7e
08:31:57  sing-box[31668]: created by github.com/sagernet/sing-mux.(*Service).NewConnection.func1 in goroutine 26652
08:31:57  sing-box[31668]:         github.com/sagernet/[email protected]/server.go:73 +0xde

Supporter

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.
  • [X] 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.

amirhosss avatar May 05 '24 09:05 amirhosss

i have very similar crash https://pastebin.com/XBDGZNC5 with this server config https://pastebin.com/6VZjFnVy on 1.9.1

BK8000L avatar Jun 07 '24 20:06 BK8000L

@amirhosss why did you close?

BK8000L avatar Jun 26 '24 06:06 BK8000L

I removed the domain_strategy in the direct outbound, which helps it run for a longer period, but the panic occurred again. So I reopen it.

amirhosss avatar Jun 26 '24 21:06 amirhosss

@amirhosss it crashes randomly i don't think domain_strategy makes any difference

BK8000L avatar Jun 27 '24 02:06 BK8000L

Same on sing-box dev-next (3bb02cb) Nekobox 1.2.9 as client

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

goroutine 9035281 [running]:
github.com/sagernet/sing-mux.(*wrapStream).Read(0x0?, {0xc0028deaec?, 0xc003ea3a40?, 0x457409?})
        github.com/sagernet/[email protected]/error.go:15 +0x1a
io.ReadAtLeast({0x7f23da417c10, 0xc00182cd70}, {0xc0028deaec, 0x2, 0x2}, 0x2)
        io/io.go:335 +0x90
io.ReadFull(...)
        io/io.go:354
encoding/binary.Read({0x7f23da417c10, 0xc00182cd70}, {0x18f3e90, 0x2470aa0}, {0x13a75c0, 0xc003ea3bee})
        encoding/binary/binary.go:241 +0xb4
github.com/sagernet/sing-mux.ReadStreamRequest({0x7f23da417c10, 0xc00182cd70})
        github.com/sagernet/[email protected]/protocol.go:119 +0x50
github.com/sagernet/sing-mux.(*Service).newConnection(0xc000258960, {0x18ec958, 0xc005e2ee10}, {0x18f6518, 0xc0000f3970}, {0x0, 0x0}, {{0x0, 0x0}, {{{0x0, ...}, ...}, ...}, ...})
        github.com/sagernet/[email protected]/server.go:89 +0x117
github.com/sagernet/sing-mux.(*Service).NewConnection.func1.1()
        github.com/sagernet/[email protected]/server.go:74 +0x7e
created by github.com/sagernet/sing-mux.(*Service).NewConnection.func1 in goroutine 8869621
        github.com/sagernet/[email protected]/server.go:73 +0xde
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xeb43fa]

goroutine 85537807 [running]:
github.com/sagernet/sing-mux.(*wrapStream).Read(0x0?, {0xc0019eac20?, 0xc001aaea40?, 0x457409?})
        github.com/sagernet/[email protected]/error.go:15 +0x1a
io.ReadAtLeast({0x7fe702ebf848, 0xc000d054a0}, {0xc0019eac20, 0x2, 0x2}, 0x2)
        io/io.go:335 +0x90
io.ReadFull(...)
        io/io.go:354
encoding/binary.Read({0x7fe702ebf848, 0xc000d054a0}, {0x18f3e90, 0x2470aa0}, {0x13a75c0, 0xc001aaebee})
        encoding/binary/binary.go:241 +0xb4
github.com/sagernet/sing-mux.ReadStreamRequest({0x7fe702ebf848, 0xc000d054a0})
        github.com/sagernet/[email protected]/protocol.go:119 +0x50
github.com/sagernet/sing-mux.(*Service).newConnection(0xc00009ac30, {0x18ec958, 0xc001d44510}, {0x18f6518, 0xc0000ee840}, {0x0, 0x0}, {{0x0, 0x0}, {{{0x0, ...}, ...}, ...}, ...})
        github.com/sagernet/[email protected]/server.go:89 +0x117
github.com/sagernet/sing-mux.(*Service).NewConnection.func1.1()
        github.com/sagernet/[email protected]/server.go:74 +0x7e
created by github.com/sagernet/sing-mux.(*Service).NewConnection.func1 in goroutine 77528998
        github.com/sagernet/[email protected]/server.go:73 +0xde

0x0737 avatar Aug 16 '24 06:08 0x0737

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

goroutine 1332479 [running]: bytes.(*Reader).Read(0xc003832ba0, {0xc001af7000?, 0x1764460?, 0x12cc7c0?}) bytes/reader.go:44 +0x7a bufio.(*Reader).fill(0xc0037c2c60) bufio/bufio.go:110 +0x103 bufio.(*Reader).ReadSlice(0xc0037c2c60, 0xa) bufio/bufio.go:376 +0x29 bufio.(*Reader).ReadLine(0xc0037c2c60) bufio/bufio.go:405 +0x25 net/textproto.(*Reader).readLineSlice(0xc001bfae70, 0xffffffffffffffff) net/textproto/reader.go:64 +0xa5 net/textproto.(*Reader).ReadLine(...) net/textproto/reader.go:44 net/http.readRequest(0xc0037c2c60) net/http/request.go:1096 +0xb0 github.com/sagernet/sing-box/common/sniff.HTTPHost({0x7dfec7?, 0xc00512dfa8?}, 0xc002a28600, {0x17643c0, 0xc003832ba0?}) github.com/sagernet/sing-box/common/sniff/http.go:15 +0x15e github.com/sagernet/sing-box/common/sniff.PeekStream.func1(0x15c5fd0) github.com/sagernet/sing-box/common/sniff/sniff.go:46 +0x104 created by github.com/sagernet/sing-box/common/sniff.PeekStream in goroutine 1332476 github.com/sagernet/sing-box/common/sniff/sniff.go:45 +0x478

MikuChat avatar Sep 03 '24 14:09 MikuChat

same on armbian of rk3399, but I encountered it instantly

armbian-rk3399:~:#  sing-box check -c /etc/sing-box/config.json    

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

goroutine 1 [running]:
time.(*Ticker).Stop(...)
        time/tick.go:53
github.com/sagernet/sing/common/ntp.(*Service).Close(0xfb98e0?)
        github.com/sagernet/[email protected]/common/ntp/service.go:110 +0x1c
github.com/sagernet/sing-box/adapter.(*lifecycleServiceWrapper).Close(0x0?)
        github.com/sagernet/sing-box/adapter/lifecycle_legacy.go:51 +0x28
github.com/sagernet/sing-box.(*Box).Close(0x40004537a0)
        github.com/sagernet/sing-box/box.go:414 +0x12c
main.check()
        github.com/sagernet/sing-box/cmd/sing-box/cmd_check.go:39 +0x124
main.init.func1(0x4000358000?, {0x400029eda0?, 0x4?, 0x1100cde?})
        github.com/sagernet/sing-box/cmd/sing-box/cmd_check.go:16 +0x1c
github.com/spf13/cobra.(*Command).execute(0x1e2d000, {0x400029ed80, 0x2, 0x2})
        github.com/spf13/[email protected]/command.go:989 +0x818
github.com/spf13/cobra.(*Command).ExecuteC(0x1e2cd20)
        github.com/spf13/[email protected]/command.go:1117 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/[email protected]/command.go:1041
main.main()
        github.com/sagernet/sing-box/cmd/sing-box/main.go:8 +0x24

14790897 avatar Apr 16 '25 08:04 14790897

@14790897 no, this is not related to armbian or arm or this issue, your issue is https://github.com/SagerNet/sing-box/issues/2839

BK8000L avatar Apr 16 '25 09:04 BK8000L