X Tutup
The Wayback Machine - https://web.archive.org/web/20201017054356/https://github.com/json-iterator/go/issues/462
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

nil pointer panic in reflect2 wrapType #462

Open
fasaxc opened this issue May 5, 2020 · 2 comments
Open

nil pointer panic in reflect2 wrapType #462

fasaxc opened this issue May 5, 2020 · 2 comments

Comments

@fasaxc
Copy link

@fasaxc fasaxc commented May 5, 2020

Not sure if this belongs here on in the reflect2 package but, in a CI run of our project, we hit the following panic (using the kubernetes client to list some custom resources):

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

goroutine 165 [running]:
github.com/modern-go/reflect2.(*frozenConfig).wrapType(0xc00036d150, 0xc000666a00, 0xc0001914a0, 0x0, 0x0)
	/go/pkg/mod/github.com/modern-go/reflect2@v1.0.1/reflect2.go:168 +0x6f
github.com/modern-go/reflect2.(*frozenConfig).Type2(0xc00036d150, 0xc000666a00, 0xc0001914a0, 0x1, 0xc000b6e6e0)
	/go/pkg/mod/github.com/modern-go/reflect2@v1.0.1/reflect2.go:161 +0xa1
github.com/modern-go/reflect2.(*UnsafeStructField).Type(0xc000c08000, 0xe0, 0x22900fb)
	/go/pkg/mod/github.com/modern-go/reflect2@v1.0.1/unsafe_field.go:37 +0x45
github.com/json-iterator/go.describeStruct(0xc000c01e30, 0x2855940, 0xc000c01e90, 0x7f0300023d98)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect_extension.go:349 +0xab2
github.com/json-iterator/go.decoderOfStruct(0xc000c01e30, 0x2855940, 0xc000c01e90, 0x0, 0x0)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect_struct_decoder.go:14 +0xb6
github.com/json-iterator/go._createDecoderOfType(0xc000c01e30, 0x2855940, 0xc000c01e90, 0xc000b87998, 0xc0003d2f00)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:176 +0x4aa
github.com/json-iterator/go.createDecoderOfType(0xc000c01e30, 0x2855940, 0xc000c01e90, 0x0, 0x0)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:142 +0x10b
github.com/json-iterator/go.decoderOfType(0xc000c01e30, 0x2855940, 0xc000c01e90, 0x22900f0, 0x1)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:124 +0x78
github.com/json-iterator/go.describeStruct(0xc00080bc40, 0x2855940, 0xc000bf17d0, 0x7f030000be34)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect_extension.go:380 +0xa4f
github.com/json-iterator/go.decoderOfStruct(0xc00080bc40, 0x2855940, 0xc000bf17d0, 0x0, 0x0)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect_struct_decoder.go:14 +0xb6
github.com/json-iterator/go._createDecoderOfType(0xc00080bc40, 0x2855940, 0xc000bf17d0, 0xc0009e7e28, 0x212e0c0)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:176 +0x4aa
github.com/json-iterator/go.createDecoderOfType(0xc00080bc40, 0x2855940, 0xc000bf17d0, 0x0, 0x0)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:142 +0x10b
github.com/json-iterator/go.decoderOfType(0xc00080bc40, 0x2855940, 0xc000bf17d0, 0x22900f0, 0x1)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:124 +0x78
github.com/json-iterator/go.decoderOfSlice(0xc000bf16e0, 0x28558a0, 0xc000b95740, 0x0, 0x0)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect_slice.go:12 +0x105
github.com/json-iterator/go._createDecoderOfType(0xc000bf16e0, 0x28558a0, 0xc000b95740, 0xc0009e7e18, 0xc0003d2f00)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:180 +0x4ff
github.com/json-iterator/go.createDecoderOfType(0xc000bf16e0, 0x28558a0, 0xc000b95740, 0x0, 0x0)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:142 +0x10b
github.com/json-iterator/go.decoderOfType(0xc000bf16e0, 0x28558a0, 0xc000b95740, 0x22900f0, 0x1)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:124 +0x78
github.com/json-iterator/go.describeStruct(0xc00080c380, 0x2855940, 0xc000bf0f30, 0x1fbd6)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect_extension.go:380 +0xa4f
github.com/json-iterator/go.decoderOfStruct(0xc00080c380, 0x2855940, 0xc000bf0f30, 0x0, 0x0)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect_struct_decoder.go:14 +0xb6
github.com/json-iterator/go._createDecoderOfType(0xc00080c380, 0x2855940, 0xc000bf0f30, 0xc0009e7dc8, 0xc0003d2f00)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:176 +0x4aa
github.com/json-iterator/go.createDecoderOfType(0xc00080c380, 0x2855940, 0xc000bf0f30, 0x0, 0x0)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:142 +0x10b
github.com/json-iterator/go.decoderOfType(0xc00080c380, 0x2855940, 0xc000bf0f30, 0x0, 0x0)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:124 +0x78
github.com/json-iterator/go.(*frozenConfig).DecoderOf(0xc00049a1e0, 0x2855800, 0xc000bf0e70, 0x2855800, 0xc000bf0e70)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:114 +0x111
github.com/json-iterator/go.(*Iterator).ReadVal(0xc0007cac60, 0x2199a00, 0xc000344070)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/reflect.go:72 +0x1ce
github.com/json-iterator/go.(*frozenConfig).Unmarshal(0xc00049a1e0, 0xc000ba6c00, 0x2d7, 0x600, 0x2199a00, 0xc000344070, 0x0, 0x0)
	/go/pkg/mod/github.com/json-iterator/go@v1.1.8/config.go:348 +0xd2
k8s.io/apimachinery/pkg/runtime/serializer/json.(*Serializer).Decode(0xc0000d4050, 0xc000ba6c00, 0x2d7, 0x600, 0x0, 0x27cb780, 0xc000344070, 0x3d, 0x1, 0x0, ...)
	/go/pkg/mod/k8s.io/apimachinery@v0.17.2/pkg/runtime/serializer/json/json.go:263 +0x600
k8s.io/apimachinery/pkg/runtime.WithoutVersionDecoder.Decode(0x27b2c20, 0xc0000d4050, 0xc000ba6c00, 0x2d7, 0x600, 0x0, 0x27cb780, 0xc000344070, 0xc0008c7600, 0xc0008c7500, ...)
	/go/pkg/mod/k8s.io/apimachinery@v0.17.2/pkg/runtime/helper.go:252 +0x97
k8s.io/client-go/rest.Result.Into(0xc000ba6c00, 0x2d7, 0x600, 0xc000483c20, 0x10, 0x0, 0x0, 0xc8, 0x27b5820, 0xc000bf4360, ...)
	/go/pkg/mod/k8s.io/client-go@v0.17.2/rest/request.go:1182 +0xba
...

We've only seen the panic once so far despite running many CI runs daily.

@AllenX2018
Copy link
Collaborator

@AllenX2018 AllenX2018 commented May 8, 2020

Thanks for reporting! Can you provide more information to help us to find out the problem? What's the input when calling Unmarshal() ?

@fasaxc
Copy link
Author

@fasaxc fasaxc commented May 11, 2020

I'm not sure, this was called from deep inside the Kubernetes client, which doing a List operation of a custom resource. Presumably it was parsing the list response.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
X Tutup