modern-go / reflect2

reflect api without runtime reflect.Value cost
Apache License 2.0
758 stars 73 forks source link

nil pointer panic in reflect2 Type2 #22

Open cabuda opened 3 years ago

cabuda commented 3 years ago

go version is 1.15.5 I got panic when I use jsoniter.Unmarshal,the input object type is

struct {
    Data  json.RawMessage     `json:"data"`
    Extra map[string]interface{} `json:"extra"`
}{}
recover from panic: err=runtime error: invalid memory address or nil pointer dereference stack=goroutine 24838623 [running]:
runtime/debug.Stack(0xc0002283f0, 0x0, 0xdf23865)
/usr/local/go/src/runtime/debug/stack.go:24 +0x9f
xxxxxxxxx(0xdf2b129, 0x6, 0xdf21b8d, 0x4, 0xc0c5217400)
xxxxx:244 +0x30a
panic(0xd39d2a0, 0x14396cd0)
/usr/local/go/src/runtime/panic.go:969 +0x1b9
sync.(*Map).Store(0xc0ca8046c0, 0xd1a7520, 0xc0c53a5298, 0xdd28c00, 0xc0c53ec700)
/usr/local/go/src/sync/map.go:151 +0x365
github.com/modern-go/reflect2.(*frozenConfig).Type2(0xc000206ba0, 0xecd8b40, 0xd0a0f20, 0x0, 0x0)
/opt/tiger/compile_path/pkg/mod/github.com/modern-go/reflect2@v1.0.1/reflect2.go:162 +0x10e
github.com/modern-go/reflect2.(*frozenConfig).TypeOf(0xc000206ba0, 0xd0a0f20, 0x0, 0xc0c3cee4b8, 0x4f3614d)
/opt/tiger/compile_path/pkg/mod/github.com/modern-go/reflect2@v1.0.1/reflect2.go:149 +0xb7
github.com/modern-go/reflect2.TypeOf(...)
/opt/tiger/compile_path/pkg/mod/github.com/modern-go/reflect2@v1.0.1/reflect2.go:211
github.com/modern-go/reflect2.TypeOfPtr(...)
/opt/tiger/compile_path/pkg/mod/github.com/modern-go/reflect2@v1.0.1/reflect2.go:215
github.com/json-iterator/go.(*frozenConfig).escapeHTML(0xc0c53ad180, 0xc0c53f3470)
/opt/tiger/compile_path/pkg/mod/github.com/json-iterator/go@v1.1.10/config.go:271 +0x46
github.com/json-iterator/go.Config.Froze(0x0, 0x1010100, 0x0, 0x0, 0x100, 0xc0c53f3300, 0x30)
/opt/tiger/compile_path/pkg/mod/github.com/json-iterator/go@v1.1.10/config.go:155 +0x2e7
github.com/json-iterator/go.Config.frozeWithCacheReuse(0x0, 0x1010100, 0x0, 0x0, 0x100, 0x0, 0x0, 0x0, 0xe944ea0)
/opt/tiger/compile_path/pkg/mod/github.com/json-iterator/go@v1.1.10/config.go:174 +0x114
github.com/json-iterator/go.(*Decoder).UseNumber(...)
/opt/tiger/compile_path/pkg/mod/github.com/json-iterator/go@v1.1.10/adapter.go:103