bytedance / sonic

A blazingly fast JSON serializing & deserializing library
Apache License 2.0
6.8k stars 333 forks source link

[ast] invalid memory address or nil pointer dereference #605

Open luoyuahui opened 7 months ago

luoyuahui commented 7 months ago

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

goroutine 215 [running]: github.com/bytedance/sonic/internal/native.Quote(0xc0000c9d00?, 0xfa1afe?, 0x2811980?, 0x0?, 0xc00936a000?) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/internal/native/dispatch_amd64.go:103 +0x15 github.com/bytedance/sonic/ast.quote(0xc009d72498, {0x0?, 0xc00936a000?}) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/ast/api_amd64.go:53 +0x179 github.com/bytedance/sonic/ast.(Node).encodeString(0xc009d72498?, 0xc009d72498?) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/ast/encode.go:177 +0xb3 github.com/bytedance/sonic/ast.(Node).encode(...) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/ast/encode.go:134 github.com/bytedance/sonic/ast.(Pair).encode(0xc0005b0f00, 0xc009d72498) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/ast/encode.go:235 +0x586 github.com/bytedance/sonic/ast.(Node).encodeObject(...) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/ast/encode.go:274 github.com/bytedance/sonic/ast.(Node).encode(0xc0003afcf8, 0xc009d72498) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/ast/encode.go:133 +0x656 github.com/bytedance/sonic/ast.(Node).encodeArray(0xc00309f218, 0xc009d72498) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/ast/encode.go:217 +0x32c github.com/bytedance/sonic/ast.(Node).encode(...) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/ast/encode.go:132 github.com/bytedance/sonic/ast.(Pair).encode(0xc00309f208, 0xc009d72498) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/ast/encode.go:235 +0x566 github.com/bytedance/sonic/ast.(Node).encodeObject(...) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/ast/encode.go:258 github.com/bytedance/sonic/ast.(Node).encode(0xc0089d5398, 0xc009d72498) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/ast/encode.go:133 +0x30b github.com/bytedance/sonic/ast.(*Node).MarshalJSON(0x16174c0?) C:/Users/123/go/pkg/mod/github.com/bytedance/sonic@v1.10.2/ast/encode.go:96 +0x2e

AsterDY commented 7 months ago

are you using ast.Node concurrently?

luoyuahui commented 7 months ago

are you using ast.Node concurrently?

one ast object just run in one goroutine

root, err := sonic.Get([]byte(` ...`))
...
root.Set("subkey", ast.NewAny(newval1))
root.MarshalJSON();
....
root.Set("subkey", ast.NewAny(newval2))
root.MarshalJSON();
AsterDY commented 7 months ago

so please give reproducible codes or link