Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] panic: reflect: call of reflect.Value.Elem on zero Value #9

Closed
MoeGrid opened this issue Sep 19, 2024 · 3 comments
Closed

[BUG] panic: reflect: call of reflect.Value.Elem on zero Value #9

MoeGrid opened this issue Sep 19, 2024 · 3 comments

Comments

@MoeGrid
Copy link
Contributor

MoeGrid commented Sep 19, 2024

8月5日的两个commit会出现报错

panic: reflect: call of reflect.Value.Elem on zero Value [recovered]
	panic: reflect: call of reflect.Value.Elem on zero Value

goroutine 1 [running]:
encoding/json.(*encodeState).marshal.func1()
	C:/Users/***/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/encoding/json/encode.go:293 +0x6d
panic({0xfc5dc0?, 0xc0004ca7c8?})
	C:/Users/***/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/runtime/panic.go:770 +0x132
reflect.Value.Elem({0x0?, 0x0?, 0x106e979?})
	C:/Users/***/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/reflect/value.go:1277 +0x195
sub2sing-box/model.(*Outbound).MarshalJSON(0xc0006a7190)
	C:/Users/***/GolandProjects/sub2sing-box/model/outbound.go:89 +0x1b8
encoding/json.addrMarshalerEncoder(0xc0004b6240, {0x10587a0?, 0xc0006a7190?, 0x3?}, {0x97?, 0x0?})
	C:/Users/***/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/encoding/json/encode.go:459 +0x15a
encoding/json.condAddrEncoder.encode({0x10d3d48?, 0xc00043dbf0?}, 0xb121bf?, {0x10587a0?, 0xc0006a7190?, 0xf9a4c0?}, {0x40?, 0xa5?})
	C:/Users/***/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/encoding/json/encode.go:891 +0x44
encoding/json.arrayEncoder.encode({0x0?}, 0xc0004b6240, {0xf99540?, 0xc0001bc9e0?, 0xc00045e188?}, {0xd7?, 0xee?})
	C:/Users/***/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/encoding/json/encode.go:847 +0xcf
encoding/json.sliceEncoder.encode({0xf9a4c0?}, 0xc0004b6240, {0xf99540?, 0xc0001bc9e0?, 0x10000c0001bc9d0?}, {0xc?, 0x0?})
	C:/Users/***/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/encoding/json/encode.go:820 +0x347
encoding/json.structEncoder.encode({{{0xc00042e008, 0x7, 0x8}, 0xc0000a8510, 0xc0000a8540}}, 0xc0004b6240, {0x103c460?, 0xc0001bc9a0?, 0x9f1d7b?}, {0x0, ...})
	C:/Users/***/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/encoding/json/encode.go:704 +0x21e
encoding/json.(*encodeState).reflectValue(0xc0004b6240, {0x103c460?, 0xc0001bc9a0?, 0x9f2125?}, {0x38?, 0x0?})
	C:/Users/***/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/encoding/json/encode.go:321 +0x73
encoding/json.(*encodeState).marshal(0x9f1d7b?, {0x103c460?, 0xc0001bc9a0?}, {0x8?, 0x0?})
	C:/Users/***/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/encoding/json/encode.go:297 +0xc5
encoding/json.Marshal({0x103c460, 0xc0001bc9a0})
	C:/Users/***/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.5.windows-amd64/src/encoding/json/encode.go:163 +0xd0
sub2sing-box/common.MergeTemplate({0xc000606000, 0x6a, 0xc000464190?}, {0xc000022280, 0x31})
	C:/Users/***/GolandProjects/sub2sing-box/common/convert.go:224 +0x99d
sub2sing-box/common.Convert({0xc0004b2030?, 0x0?, 0x0?}, {0x0, 0x0, 0x0?}, {0xc000022280, 0x31}, {0x0, 0x0}, ...)
	C:/Users/***/GolandProjects/sub2sing-box/common/convert.go:89 +0x91f
sub2sing-box/cmd.convertRun(0xc0001dda00?, {0x106f494?, 0x4?, 0x106f410?})
	C:/Users/***/GolandProjects/sub2sing-box/cmd/convert.go:52 +0x12f
github.com/spf13/cobra.(*Command).execute(0x16c9820, {0xc0004ba000, 0x6, 0x6})
	C:/Users/***/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:987 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0x16d6780)
	C:/Users/***/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(0x0?)
	C:/Users/***/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039 +0x13
main.main()
	C:/Users/***/GolandProjects/sub2sing-box/main.go:9 +0x1a
@nitezs
Copy link
Owner

nitezs commented Sep 19, 2024

这个BUG是怎么触发的,需要复现一下。

@MoeGrid
Copy link
Contributor Author

MoeGrid commented Sep 19, 2024

这个BUG是怎么触发的,需要复现一下。

我用以下参数做的测试,发现模板文件outbounds中只要带有direct、block、dns这三个就会出错,删掉这三个就没问题了

命令参数
convert -o config.json -s http://xxx.com/bug.txt -t config.tpl.json

订阅链接内容

c3M6Ly9ZV1Z6TFRFeU9DMW5ZMjA2ZUhoNGVIaDRlSGg0ZUhnQHh4eHh4Lnh4eHgueHh4OjIwMDAxLz9wbHVnaW49b2Jmcy1sb2NhbCUzQm9iZnMlM0RodHRwJTNCb2Jmcy1ob3N0JTNEbUM1aWFhSGloVC5taWNyb3NvZnQuY29tJmdyb3VwPVNXMXRWR1ZzWldOdmJRI0hLRyUyMDAxCnNzOi8vWVdWekxURXlPQzFuWTIwNmVIaDRlSGg0ZUhoNGVIZ0B4eHh4eC54eHh4Lnh4eDoyMDAwMi8_cGx1Z2luPW9iZnMtbG9jYWwlM0JvYmZzJTNEaHR0cCUzQm9iZnMtaG9zdCUzRG1DNWlhYUhpaFQubWljcm9zb2Z0LmNvbSZncm91cD1TVzF0VkdWc1pXTnZiUSNIS0clMjAwMg

config.tpl.json内容

{
    "outbounds": [
        {
            "tag": "direct",
            "type": "direct"
        },
        {
            "tag": "block",
            "type": "block"
        },
        {
            "tag": "dns-out",
            "type": "dns"
        },
        {
            "tag": "Proxy",
            "outbounds": [
                "direct",
                "block",
                "<all-proxy-tags>"
            ],
            "interrupt_exist_connections": true,
            "type": "selector"
        }
    ]
}

@nitezs nitezs closed this as completed in a1dcc18 Sep 19, 2024
@nitezs
Copy link
Owner

nitezs commented Sep 19, 2024

重写 MarshalJSON 没测试 😿
已经修复了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants