Skip to content

reflect: unexpected fault address 0x0 #68355

Closed as not planned
Closed as not planned
@shaj13

Description

@shaj13

Go version

go version go1.22.1 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY='<internal>'
GONOSUMDB='<internal>'
GOOS='linux'
GOPATH='/go'
GOPRIVATE='<internal>'
GOPROXY='<internal>'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1448936908=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Two months ago, we upgraded from 1.21 to 1.22.1. Today, we received an incident report about a panic. Upon reviewing the logs, we found that it originated from the reflect package due to a fault address. The issue occurs when a Kubernetes object is passed to the apimachinery unstructured, which uses reflection behind the scenes.

import (
	v1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
	"k8s.io/apimachinery/pkg/runtime"
	v1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1"
)

	if err := runtime.
		DefaultUnstructuredConverter.
		FromUnstructured(
			u.UnstructuredContent(),
			v,
		); err != nil {
		return nil, err
	}

The UnstructuredContent() never returns nil
image

What did you see happen?

2024-07-08T14:12:49.881927297Z unexpected fault address 0x0
2024-07-08T14:12:49.881958704Z fatal error: fault
2024-07-08T14:12:49.886359489Z [signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x4c7ec5]
2024-07-08T14:12:49.886370829Z 
2024-07-08T14:12:49.886377957Z goroutine 130 gp=0xc000254fc0 m=6 mp=0xc00049a008 [running]:
2024-07-08T14:12:49.886383321Z runtime.throw({0x1c1dcd6?, 0xc003082750?})
2024-07-08T14:12:49.886388154Z 	/usr/local/go/src/runtime/panic.go:1023 +0x5c fp=0xc002af8978 sp=0xc002af8948 pc=0x43d39c
2024-07-08T14:12:49.886392280Z runtime.sigpanic()
2024-07-08T14:12:49.886395705Z 	/usr/local/go/src/runtime/signal_unix.go:895 +0x285 fp=0xc002af89d8 sp=0xc002af8978 pc=0x455f25
2024-07-08T14:12:49.886398845Z internal/abi.(*Type).HasName(...)
2024-07-08T14:12:49.886402324Z 	/usr/local/go/src/internal/abi/type.go:172
2024-07-08T14:12:49.886405359Z reflect.directlyAssignable(0x10?, 0x1ed8308?)
2024-07-08T14:12:49.886409097Z 	/usr/local/go/src/reflect/type.go:1386 +0x25 fp=0xc002af8a00 sp=0xc002af89d8 pc=0x4c7ec5
2024-07-08T14:12:49.886413876Z reflect.Value.assignTo({0x6ff0040c6013c00?, 0x1e0a1d001e0a8165?, 0xc00375b2d0?}, {0x1c3588f, 0x16}, 0x18988c0, 0x0)
2024-07-08T14:12:49.886417160Z 	/usr/local/go/src/reflect/value.go:3329 +0x98 fp=0xc002af8aa8 sp=0xc002af8a00 pc=0x4dccd8
2024-07-08T14:12:49.886420354Z reflect.Value.MapIndex({0x197b5e0?, 0xc003ec9860?, 0x13?}, {0x6ff0040c6013c00, 0x1e0a1d001e0a8165, 0xf745010013801c00})
2024-07-08T14:12:49.886423642Z 	/usr/local/go/src/reflect/value.go:1821 +0xe8 fp=0xc002af8b18 sp=0xc002af8aa8 pc=0x4d7728
2024-07-08T14:12:49.886428433Z k8s.io/apimachinery/pkg/runtime.structFromUnstructured({0x197b5e0?, 0xc003ec9860?, 0x7f1b79762d98?}, {0x1bd1820?, 0xc003082600?, 0x41a2f8?}, 0xc002af9778)
2024-07-08T14:12:49.886442321Z 	vendor/k8s.io/apimachinery/pkg/runtime/converter.go:546 +0x49c fp=0xc002af8c80 sp=0xc002af8b18 pc=0xc7c5bc
2024-07-08T14:12:49.886447122Z k8s.io/apimachinery/pkg/runtime.fromUnstructured({0x1951ce0?, 0xc0047ccfb0?, 0x1?}, {0x1bd1820?, 0xc003082600?, 0xc66e9a?}, 0xc002af9778)
2024-07-08T14:12:49.886450668Z 	vendor/k8s.io/apimachinery/pkg/runtime/converter.go:359 +0x3cf fp=0xc002af8de8 sp=0xc002af8c80 pc=0xc79daf
2024-07-08T14:12:49.886454051Z k8s.io/apimachinery/pkg/runtime.sliceFromUnstructured({0x186eec0?, 0xc0035f4b40?, 0x411c7b?}, {0x18755e0?, 0xc004318140?, 0xc002de2e10?}, 0xc002af9778)
2024-07-08T14:12:49.886457313Z 	vendor/k8s.io/apimachinery/pkg/runtime/converter.go:488 +0x8c5 fp=0xc002af8f68 sp=0xc002af8de8 pc=0xc7bc05
2024-07-08T14:12:49.886460485Z k8s.io/apimachinery/pkg/runtime.fromUnstructured({0x186eec0?, 0xc0035f4b40?, 0x2?}, {0x18755e0?, 0xc004318140?, 0x98?}, 0xc002af9778)
2024-07-08T14:12:49.886463787Z 	vendor/k8s.io/apimachinery/pkg/runtime/converter.go:355 +0x412 fp=0xc002af90d0 sp=0xc002af8f68 pc=0xc79df2
2024-07-08T14:12:49.886466748Z k8s.io/apimachinery/pkg/runtime.structFromUnstructured({0x197b5e0?, 0xc003ec9710?, 0x411c7b?}, {0x1c03220?, 0xc004318110?, 0xc002de2e10?}, 0xc002af9778)
2024-07-08T14:12:49.886469993Z 	vendor/k8s.io/apimachinery/pkg/runtime/converter.go:550 +0x816 fp=0xc002af9238 sp=0xc002af90d0 pc=0xc7c936
2024-07-08T14:12:49.886473076Z k8s.io/apimachinery/pkg/runtime.fromUnstructured({0x197b5e0?, 0xc003ec9710?, 0x2?}, {0x1c03220?, 0xc004318110?, 0x98?}, 0xc002af9778)
2024-07-08T14:12:49.886476340Z 	vendor/k8s.io/apimachinery/pkg/runtime/converter.go:359 +0x3cf fp=0xc002af93a0 sp=0xc002af9238 pc=0xc79daf
2024-07-08T14:12:49.886479386Z k8s.io/apimachinery/pkg/runtime.structFromUnstructured({0x197b5e0?, 0xc003ec2270?, 0xc002af9590?}, {0x1ad80a0?, 0xc004318008?, 0xc002af9670?}, 0xc002af9778)
2024-07-08T14:12:49.886482403Z 	vendor/k8s.io/apimachinery/pkg/runtime/converter.go:550 +0x816 fp=0xc002af9508 sp=0xc002af93a0 pc=0xc7c936
2024-07-08T14:12:49.886508041Z k8s.io/apimachinery/pkg/runtime.fromUnstructured({0x197b5e0?, 0xc003ec2270?, 0x0?}, {0x1ad80a0?, 0xc004318008?, 0x630b4?}, 0xc002af9778)
2024-07-08T14:12:49.886513850Z 	vendor/k8s.io/apimachinery/pkg/runtime/converter.go:359 +0x3cf fp=0xc002af9670 sp=0xc002af9508 pc=0xc79daf
2024-07-08T14:12:49.886517216Z k8s.io/apimachinery/pkg/runtime.(*unstructuredConverter).FromUnstructuredWithValidation(0x2ce5e60, 0xc003ec2270, {0x1be1140, 0xc004318008}, 0x0)
2024-07-08T14:12:49.886520437Z 	vendor/k8s.io/apimachinery/pkg/runtime/converter.go:247 +0x290 fp=0xc002af9800 sp=0xc002af9670 pc=0xc793b0
2024-07-08T14:12:49.886523599Z k8s.io/apimachinery/pkg/runtime.(*unstructuredConverter).FromUnstructured(...)
2024-07-08T14:12:49.886528439Z 	vendor/k8s.io/apimachinery/pkg/runtime/converter.go:274

What did you expect to see?

reflect package does not panic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions