SagerNet / sing-box

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

1.10.0-alpha.1 crash on simple config file #1799

Closed read8873 closed 4 weeks ago

read8873 commented 1 month ago

Operating system

Windows

System version

1.10.0-alpha.1

Installation type

Original sing-box Command Line

If you are using a graphical client, please provide the version of the client.

No response

Version

No response

Description

1.10.0-alpha.1 crash on simple config file

Reproduction

Logs

panic: runtime error: slice bounds out of range [511:119]

goroutine 1 [running]:
github.com/sagernet/sing/common/json/internal/contextjson.(*Decoder).refill(0xc00014fb80)
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/stream.go:151 +0x1c5
github.com/sagernet/sing/common/json/internal/contextjson.(*Decoder).peek(0xc00014fb80)
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/stream.go:522 +0x25
github.com/sagernet/sing/common/json/internal/contextjson.(*Decoder).Token(0xc00014fb80)
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/stream.go:371 +0x1c
github.com/sagernet/sing/common/json/badjson.(*JSONObject).decodeJSON(0xc0001433b0, 0xc00014fb80)
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/badjson/object.go:85 +0x75
github.com/sagernet/sing/common/json/badjson.(*JSONObject).UnmarshalJSON(0xc0001433b0, {0xc000293a1d, 0x277, 0xc3e3})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/badjson/object.go:69 +0x1f7
github.com/sagernet/sing-box/option.UnmarshallExcluded({0xc000293a1d, 0x277, 0xc3e3}, {0x1d2d260?, 0xc000705f80?}, {0x1ebfd80, 0xc0007062e8})
        github.com/sagernet/sing-box/option/json.go:55 +0x9f
github.com/sagernet/sing-box/option.(*Outbound).UnmarshalJSON(0xc000705f80, {0xc000293a1d, 0x277, 0xc3e3})
        github.com/sagernet/sing-box/option/outbound.go:98 +0x85
github.com/sagernet/sing/common/json/internal/contextjson.(*decodeState).object(0xc0000ad068, {0x1f87700?, 0xc000705f80?, 0x1d47460?})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/decode.go:619 +0x6b3
github.com/sagernet/sing/common/json/internal/contextjson.(*decodeState).value(0xc0000ad068, {0x1f87700?, 0xc000705f80?, 0x8d?})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/decode.go:379 +0x3e
github.com/sagernet/sing/common/json/internal/contextjson.(*decodeState).array(0xc0000ad068, {0x1d47460?, 0xc00018a658?, 0x0?})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/decode.go:565 +0x52f
github.com/sagernet/sing/common/json/internal/contextjson.(*decodeState).value(0xc0000ad068, {0x1d47460?, 0xc00018a658?, 0x9?})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/decode.go:369 +0x74
github.com/sagernet/sing/common/json/internal/contextjson.(*decodeState).object(0xc0000ad068, {0x1d2d220?, 0xc00018a600?, 0xc0000c4d30?})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/decode.go:777 +0xce5
github.com/sagernet/sing/common/json/internal/contextjson.(*decodeState).value(0xc0000ad068, {0x1d2d220?, 0xc00018a600?, 0xc0000c4d80?})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/decode.go:379 +0x3e
github.com/sagernet/sing/common/json/internal/contextjson.(*decodeState).unmarshal(0xc0000ad068, {0x1d2d220?, 0xc00018a600?})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/decode.go:181 +0x11e
github.com/sagernet/sing/common/json/internal/contextjson.(*Decoder).Decode(0xc0000ad040, {0x1d2d220, 0xc00018a600})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/stream.go:73 +0x15a
github.com/sagernet/sing-box/option.(*Options).UnmarshalJSON(0xc00018a600, {0xc000210000, 0x1cdee, 0x1fe00})
        github.com/sagernet/sing-box/option/config.go:26 +0xaa
github.com/sagernet/sing/common/json/internal/contextjson.(*decodeState).object(0xc0000acf28, {0x1dba440?, 0xc00018a600?, 0xc0000c5178?})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/decode.go:619 +0x6b3
github.com/sagernet/sing/common/json/internal/contextjson.(*decodeState).value(0xc0000acf28, {0x1dba440?, 0xc00018a600?, 0xc0000c51c8?})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/decode.go:379 +0x3e
github.com/sagernet/sing/common/json/internal/contextjson.(*decodeState).unmarshal(0xc0000acf28, {0x1dba440?, 0xc00018a600?})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/decode.go:181 +0x11e
github.com/sagernet/sing/common/json/internal/contextjson.(*Decoder).Decode(0xc0000acf00, {0x1dba440, 0xc00018a600})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/internal/contextjson/stream.go:73 +0x15a
github.com/sagernet/sing/common/json.UnmarshalExtended[...]({0xc0001ce000, 0x1cdee, 0x1cdef})
        github.com/sagernet/sing@v0.5.0-alpha.4/common/json/unmarshal.go:14 +0x23a
main.readConfigAt({0xc0000080f0, 0xf})
        github.com/sagernet/sing-box/cmd/sing-box/cmd_run.go:60 +0x1c8
main.readConfig()
        github.com/sagernet/sing-box/cmd/sing-box/cmd_run.go:74 +0x97
main.readConfigAndMerge()
        github.com/sagernet/sing-box/cmd/sing-box/cmd_run.go:103 +0x3a
main.create()
        github.com/sagernet/sing-box/cmd/sing-box/cmd_run.go:126 +0x78
main.run()
        github.com/sagernet/sing-box/cmd/sing-box/cmd_run.go:174 +0x10c
main.init.func25(0xc000193a00?, {0x1fc02f7?, 0x4?, 0x1fc02fb?})
        github.com/sagernet/sing-box/cmd/sing-box/cmd_run.go:30 +0x17
github.com/spf13/cobra.(*Command).execute(0x2c077e0, {0xc0000833a0, 0x2, 0x2})
        github.com/spf13/cobra@v1.8.0/command.go:987 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0x2c07ac0)
        github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.8.0/command.go:1039
main.main()
        github.com/sagernet/sing-box/cmd/sing-box/main.go:38 +0x1e


### Supporter

- [ ] I am a [sponsor](https://github.com/sponsors/nekohasekai/)

### 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.
dyhkwong commented 4 weeks ago

Should be fixed in latest versions.