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

Controller-gen panic when using go 1.22 #880

Closed
IBMRob opened this issue Feb 8, 2024 · 7 comments · Fixed by openkruise/kruise#1562
Closed

Controller-gen panic when using go 1.22 #880

IBMRob opened this issue Feb 8, 2024 · 7 comments · Fixed by openkruise/kruise#1562

Comments

@IBMRob
Copy link

IBMRob commented Feb 8, 2024

Previously we were using go 1.21 without issue. After upgrading to go 1.22 using controller-gen v0.9 it results in the following

rob@Robs-MBP ibm-appconnect % make generate
GOBIN=/Users/rob/Documents/operators/my-operator/bin go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.9.0
/Users/rob/Documents/operators/my-operator/bin/controller-gen rbac:roleName=operator crd paths="./..." output:crd:artifacts:config=config/crd/bases
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x101050bc0]

goroutine 1367 [running]:
go/types.(*Checker).handleBailout(0x14001855200, 0x14008e7bd18)
        /Users/rob/sdk/go1.22.0/src/go/types/check.go:367 +0x9c
panic({0x10131ba60?, 0x1018a7f30?})
        /Users/rob/sdk/go1.22.0/src/runtime/panic.go:770 +0x124
go/types.(*StdSizes).Sizeof(0x0, {0x1013e4c70, 0x1018b0840})
        /Users/rob/sdk/go1.22.0/src/go/types/sizes.go:228 +0x320
go/types.(*Config).sizeof(...)
        /Users/rob/sdk/go1.22.0/src/go/types/sizes.go:333
go/types.representableConst.func1({0x1013e4c70?, 0x1018b0840?})
        /Users/rob/sdk/go1.22.0/src/go/types/const.go:76 +0x9c
go/types.representableConst({0x1013eae58, 0x10187ca38}, 0x14001855200, 0x1018b0840, 0x14008e77ae8)
        /Users/rob/sdk/go1.22.0/src/go/types/const.go:106 +0x2b0
go/types.(*Checker).representation(0x14001855200, 0x1400a7510c0, 0x1018b0840)
        /Users/rob/sdk/go1.22.0/src/go/types/const.go:256 +0x68
go/types.(*Checker).representable(0x14001855200, 0x1400a7510c0, 0x1018b0840)
        /Users/rob/sdk/go1.22.0/src/go/types/const.go:239 +0x28
go/types.(*Checker).shift(0x14001855200, 0x1400a751040, 0x1400a7510c0, {0x1013e8cf0, 0x14008e5e450}, 0x14)
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:650 +0x1d8
go/types.(*Checker).binary(0x14001855200, 0x1400a751040, {0x1013e8cf0, 0x14008e5e450}, {0x1013e9200, 0x14008e5aec0}, {0x1013e9200, 0x14008e5aee0}, 0x14, 0xd8a0e2)
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:796 +0x100
go/types.(*Checker).exprInternal(0x14001855200, 0x0, 0x1400a751040, {0x1013e8cf0, 0x14008e5e450}, {0x0, 0x0})
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:1416 +0x1d4
go/types.(*Checker).rawExpr(0x14001855200, 0x0, 0x1400a751040, {0x1013e8cf0?, 0x14008e5e450?}, {0x0?, 0x0?}, 0x0)
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).exprInternal(0x14001855200, 0x0, 0x1400a751040, {0x1013e8ba0, 0x14008e5af00}, {0x0, 0x0})
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:1320 +0x150
go/types.(*Checker).rawExpr(0x14001855200, 0x0, 0x1400a751040, {0x1013e8ba0?, 0x14008e5af00?}, {0x0?, 0x0?}, 0x0)
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).expr(0x14001855200, 0x101b05d28?, 0x1400a751040, {0x1013e8ba0?, 0x14008e5af00?})
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:1513 +0x38
go/types.(*Checker).binary(0x14001855200, 0x1400a751040, {0x1013e8cf0, 0x14008e5e480}, {0x1013e8ba0, 0x14008e5af00}, {0x1013e9200, 0x14008e5af20}, 0xd, 0xd8a0e7)
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:783 +0x70
go/types.(*Checker).exprInternal(0x14001855200, 0x0, 0x1400a751040, {0x1013e8cf0, 0x14008e5e480}, {0x0, 0x0})
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:1416 +0x1d4
go/types.(*Checker).rawExpr(0x14001855200, 0x0, 0x1400a751040, {0x1013e8cf0?, 0x14008e5e480?}, {0x0?, 0x0?}, 0x1)
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).use1(0x14001855200, {0x1013e8cf0, 0x14008e5e480}, 0x0)
        /Users/rob/sdk/go1.22.0/src/go/types/call.go:1043 +0x1c4
go/types.(*Checker).useN(...)
        /Users/rob/sdk/go1.22.0/src/go/types/call.go:1004
go/types.(*Checker).use(...)
        /Users/rob/sdk/go1.22.0/src/go/types/call.go:994
go/types.(*Checker).callExpr(0x14001855200, 0x1400a750f80, 0x14008e5c680)
        /Users/rob/sdk/go1.22.0/src/go/types/call.go:196 +0x12b0
go/types.(*Checker).exprInternal(0x14001855200, 0x0, 0x1400a750f80, {0x1013e92c0, 0x14008e5c680}, {0x0, 0x0})
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:1374 +0xd0
go/types.(*Checker).rawExpr(0x14001855200, 0x0, 0x1400a750f80, {0x1013e92c0?, 0x14008e5c680?}, {0x0?, 0x0?}, 0x0)
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).expr(0x14001855200, 0x1400a3780e0?, 0x1400a750f80, {0x1013e92c0?, 0x14008e5c680?})
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:1513 +0x38
go/types.(*Checker).exprInternal(0x14001855200, 0x0, 0x1400a750f80, {0x1013e8c60, 0x14008e5c6c0}, {0x0, 0x0})
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:1190 +0x1890
go/types.(*Checker).rawExpr(0x14001855200, 0x0, 0x1400a750f80, {0x1013e8c60?, 0x14008e5c6c0?}, {0x0?, 0x0?}, 0x0)
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:979 +0x12c
go/types.(*Checker).expr(0x14001855200, 0x0?, 0x1400a750f80, {0x1013e8c60?, 0x14008e5c6c0?})
        /Users/rob/sdk/go1.22.0/src/go/types/expr.go:1513 +0x38
go/types.(*Checker).varDecl(0x14001855200, 0x1400a367860, {0x140083b0698, 0x1, 0x1}, {0x0, 0x0}, {0x1013e8c60, 0x14008e5c6c0})
        /Users/rob/sdk/go1.22.0/src/go/types/decl.go:521 +0x140
go/types.(*Checker).objDecl(0x14001855200, {0x1013eff78, 0x1400a367860}, 0x0)
        /Users/rob/sdk/go1.22.0/src/go/types/decl.go:194 +0x7ec
go/types.(*Checker).packageObjects(0x14001855200)
        /Users/rob/sdk/go1.22.0/src/go/types/resolver.go:693 +0x468
go/types.(*Checker).checkFiles(0x14001855200, {0x140099e5680, 0x7, 0x7})
        /Users/rob/sdk/go1.22.0/src/go/types/check.go:408 +0x164
go/types.(*Checker).Files(...)
        /Users/rob/sdk/go1.22.0/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0x140003e4ea0, 0x140099f49a0)
        /Users/rob/go/pkg/mod/sigs.k8s.io/controller-tools@v0.9.0/pkg/loader/loader.go:286 +0x2d8
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0x140099f49a0)
        /Users/rob/go/pkg/mod/sigs.k8s.io/controller-tools@v0.9.0/pkg/loader/loader.go:99 +0x44
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0x140099f8330, 0x140099f49a0)
        /Users/rob/go/pkg/mod/sigs.k8s.io/controller-tools@v0.9.0/pkg/loader/refs.go:268 +0x304
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x97?)
        /Users/rob/go/pkg/mod/sigs.k8s.io/controller-tools@v0.9.0/pkg/loader/refs.go:262 +0x58
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 1
        /Users/rob/go/pkg/mod/sigs.k8s.io/controller-tools@v0.9.0/pkg/loader/refs.go:260 +0x230
make: *** [manifests] Error 2
@sbueringer
Copy link
Member

What happens if you use a recent version of controller-gen?

@xrstf
Copy link
Contributor

xrstf commented Feb 8, 2024

FWIW, https://github.com/elastic/crd-ref-docs/blob/v0.0.10 panics as well and is using controller-tools 0.13.0 already. Not the latest, I know, but at least somewhat more recent than v0.9.0.

@IBMRob
Copy link
Author

IBMRob commented Feb 8, 2024

Looks like the very latest does work - Now I need to see if Operator-SDK support support using that version.

@IBMRob IBMRob closed this as completed Feb 8, 2024
@mikkeloscar
Copy link

jFYI: I git bisect'ed Go and found that this is the commit causing the crash: golang/go@5fa4aac

Will likely open an upstream issue, didn't check check if a similar issue has been created.

@mh013370
Copy link

mh013370 commented Feb 9, 2024

We updated controller-tools to v0.14.0 in nifikop (linked above) and that avoided the panic. We'd tried v0.9.0 and v0.13.0 and they both crashed when generating CRDs.

@camilamacedo86
Copy link
Member

camilamacedo86 commented Feb 11, 2024

Operator-SDK uses Kubebuilder
It just add things on top.

Kubebuilder does not support 1.22 yet
We are in 1.21

Also, see that this project needs to be upgraded
https://github.com/kubernetes-sigs/controller-tools/blob/master/go.mod#L3
For 1.21 and going on

@sbueringer
Copy link
Member

Also, see that this project needs to be upgraded

Why? This is the minimal required Go version to compile controller-tools. That doesn't mean it can't be used with 1.21 or 1.22

enocom added a commit to GoogleCloudPlatform/cloud-sql-proxy-operator that referenced this issue Feb 16, 2024
This is currently failing on a similar issue to
kubernetes-sigs/controller-tools#880
AlexanderYastrebov added a commit to szuecs/routegroup-client that referenced this issue Mar 6, 2024
This fixes panic on go1.22, see kubernetes-sigs/controller-tools#880
and golang/go#65637

Since `go get sigs.k8s.io/controller-tools` updates transitive Kubernetes dependencies
this change removes it from dependencies in favor of fixed version in the Makefile.

Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
ttosta-google pushed a commit to GoogleCloudPlatform/cloud-sql-proxy-operator that referenced this issue Mar 19, 2024
This is currently failing on a similar issue to
kubernetes-sigs/controller-tools#880
elevran added a commit to elevran/clusterlink that referenced this issue Apr 3, 2024
controller-gen 0.13.0 panics on go1.22 - updating to 0.14.0 resolves it
This is a known issue #kubernetes-sigs/controller-tools/issues/880

Signed-off-by: Etai Lev Ran <elevran@gmail.com>
David-Wobrock added a commit to David-Wobrock/hydra-maester that referenced this issue Jun 23, 2024
David-Wobrock added a commit to David-Wobrock/hydra-maester that referenced this issue Jun 23, 2024
clamoriniere added a commit to DataDog/watermarkpodautoscaler that referenced this issue Jul 4, 2024
for now we can't move to 1.22 due to a controler-gen panic issue, see:
kubernetes-sigs/controller-tools#880
clamoriniere added a commit to DataDog/watermarkpodautoscaler that referenced this issue Jul 5, 2024
* move api to multigroup support
* move controller to multigroup support
* update to golang 1.21

for now we can't move to 1.22 due to a controler-gen panic issue, see:
kubernetes-sigs/controller-tools#880
hrak added a commit to Leaseweb/cluster-api-provider-cloudstack that referenced this issue Jul 10, 2024
hrak added a commit to Leaseweb/cluster-api-provider-cloudstack that referenced this issue Jul 10, 2024
hrak added a commit to Leaseweb/cluster-api-provider-cloudstack that referenced this issue Jul 10, 2024
hrak added a commit to Leaseweb/cluster-api-provider-cloudstack that referenced this issue Jul 11, 2024
hrak added a commit to Leaseweb/cluster-api-provider-cloudstack that referenced this issue Jul 12, 2024
hrak added a commit to Leaseweb/cluster-api-provider-cloudstack that referenced this issue Jul 16, 2024
pjonsson added a commit to pjonsson/hierarchical-namespaces that referenced this issue Aug 12, 2024
This updates golang.org/x/tools to
a later version which fixes the crash
in kubernetes-sigs/controller-tools#880,
which I believe is what is happening
on the current main branch in this
repository.
bayandin added a commit to neondatabase/autoscaling that referenced this issue Sep 5, 2024
This PR updates `controller-tools` to 0.14.0.

`controller-tools` 0.13 segfauls with `go` ≥ 1.22, which blocks
upgrading `go` (see
kubernetes-sigs/controller-tools#880).

Extracted from #1035
0x0013 added a commit to gocardless/theatre that referenced this issue Nov 26, 2024
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

Successfully merging a pull request may close this issue.

6 participants