Closed kerthcet closed 7 months ago
This is happened with controller-gen v0.13.0, when I upgrade to v0.14.0, it disappears.
Still got this on 14.0
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa7ae32]
goroutine 1 [running]:
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedPackage(0xc0006bd860, 0x0)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/parser.go:237 +0x52
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc0006bd860, {0x0, {0xc001406254, 0x3}})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/parser.go:170 +0x5a
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc00a6dcc90?, {0xc0001c28a0?, 0xc93f1a?}, {0xc001406254?, 0x3?})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:107 +0xdb
sigs.k8s.io/controller-tools/pkg/crd.namedToSchema(0xc00a6dcc90, 0xc000013890)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:254 +0x1fb
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc00a6dcc90, {0xdc9f80?, 0xc000013890})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:173 +0x5c
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc00907aa40, 0xc0000138a8)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:401 +0x7f2
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc00907aa40, {0xdc9f20?, 0xc0000138a8})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:181 +0xc5
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(0xc00907aa40)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:124 +0x112
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc0006bd860, {0xc000f588c0, {0xc001105f3c, 0x4}})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/parser.go:193 +0x2ae
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc0003ebb00?, {0x0?, 0xc93f1a?}, {0xc001105f3c?, 0x0?})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:107 +0xdb
sigs.k8s.io/controller-tools/pkg/crd.localNamedToSchema(0xc00907ae60, 0xc0017324e0)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:237 +0x18c
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc00907ae60, {0xdc9f50?, 0xc0017324e0})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:171 +0x46
sigs.k8s.io/controller-tools/pkg/crd.arrayToSchema(0xc00a6dca50, 0xc001734090)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:275 +0x10a
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc00a6dca50, {0xdc9fb0?, 0xc001734090})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:175 +0x72
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc00907b558, 0xc00172c4e0)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:401 +0x7f2
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc00907b558, {0xdc9f20?, 0xc00172c4e0})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:181 +0xc5
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(0xc00907b558)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:124 +0x112
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc0006bd860, {0xc000f588c0, {0xc00012a168, 0x18}})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/parser.go:193 +0x2ae
sigs.k8s.io/controller-tools/pkg/crd.(*schemaContext).requestSchema(0xc0003ebb00?, {0x0?, 0xc93f1a?}, {0xc00012a168?, 0x0?})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:107 +0xdb
sigs.k8s.io/controller-tools/pkg/crd.localNamedToSchema(0xc00a6dc930, 0xc001732280)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:237 +0x18c
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc00a6dc930, {0xdc9f50?, 0xc001732280})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:171 +0x46
sigs.k8s.io/controller-tools/pkg/crd.structToSchema(0xc00907bf98, 0xc00172c228)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:401 +0x7f2
sigs.k8s.io/controller-tools/pkg/crd.typeToSchema(0xc00907bf98, {0xdc9f20?, 0xc00172c228})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:181 +0xc5
sigs.k8s.io/controller-tools/pkg/crd.infoToSchema(0xc00907bf98)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/schema.go:124 +0x112
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedSchemaFor(0xc0006bd860, {0xc000f588c0, {0xc00012a138, 0x14}})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/parser.go:193 +0x2ae
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedFlattenedSchemaFor(0xc0006bd860, {0xc000f588c0, {0xc00012a138, 0x14}})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/parser.go:205 +0xcd
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedCRDFor(0xc0006bd860, {{0xc001b880ce, 0x15}, {0xc00012a138, 0x14}}, 0x0)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/spec.go:93 +0x585
sigs.k8s.io/controller-tools/pkg/crd.Generator.Generate({0x0, 0xc00029e7c8, 0x0, {0x0, 0x0, 0x0}, 0x0, {0x0, 0x0}, {0x0, ...}}, ...)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/crd/gen.go:150 +0x40b
sigs.k8s.io/controller-tools/pkg/genall.(*Runtime).Run(0xc00143d0e0)
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/pkg/genall/genall.go:272 +0x247
main.main.func1(0xc000282200?, {0xc0002d91a0?, 0x4?, 0xc92162?})
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/cmd/controller-gen/main.go:176 +0x6a
github.com/spf13/cobra.(*Command).execute(0xc000004300, {0xc000036090, 0x3, 0x3})
/home/ubuntu/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xabc
github.com/spf13/cobra.(*Command).ExecuteC(0xc000004300)
/home/ubuntu/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
/home/ubuntu/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
main.main()
/home/ubuntu/go/pkg/mod/sigs.k8s.io/controller-tools@v0.14.0/cmd/controller-gen/main.go:200 +0x2d2
I have the same with the latest version on alpine docker image 1.22-alpine and 1.21-alpine
Is anyone able to provide a minimal repo to reproduce this issue with the latest release?
(alternatively a PR with a fix and unit test which triggers the panic without the fix would also work)
@sbueringer this is not present on v0.14.0. (go1.22.1
/darwin/arm64
).
@shanduur Thx for the confirmation for your case. There seem to be other cases though: https://github.com/kubernetes-sigs/controller-tools/issues/888#issuecomment-2011069171
No idea if that is the same panic though as the issue description doesn't show a full stacktrace.
I have an older version, but a similar error occurred in v0.9.0. (go version go1.22.2 linux/amd64
)
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=0x1 addr=0x0 pc=0xa00acf]
goroutine 178 [running]:
go/types.(*Checker).handleBailout(0xc000382a00, 0xc001271d40)
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/check.go:367 +0x88
panic({0xbb0600?, 0x128fd00?})
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0xda2d78, 0x1298560})
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/sizes.go:228 +0x30f
go/types.(*Config).sizeof(...)
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/sizes.go:333
go/types.representableConst.func1({0xda2d78?, 0x1298560?})
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/const.go:76 +0x9e
go/types.representableConst({0xda90e0, 0x12645a0}, 0xc000382a00, 0x1298560, 0x0)
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/const.go:92 +0x192
go/types.(*Checker).arrayLength(0xc000382a00, {0xda73a8, 0xc0018f84c0?})
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/typexpr.go:510 +0x2d3
go/types.(*Checker).typInternal(0xc000382a00, {0xda59f8, 0xc00121ccc0}, 0x0)
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/typexpr.go:299 +0x49d
go/types.(*Checker).definedType(0xc000382a00, {0xda59f8, 0xc00121ccc0}, 0xc001271328?)
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/typexpr.go:180 +0x37
go/types.(*Checker).varType(0xc000382a00, {0xda59f8, 0xc00121ccc0})
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/typexpr.go:145 +0x25
go/types.(*Checker).structType(0xc000382a00, 0xc001b123f0, 0xc001b123f0?)
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/struct.go:113 +0x19f
go/types.(*Checker).typInternal(0xc000382a00, {0xda5968, 0xc001217320}, 0xc001b0b400)
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/typexpr.go:316 +0x1345
go/types.(*Checker).definedType(0xc000382a00, {0xda5968, 0xc001217320}, 0xc785e2?)
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/typexpr.go:180 +0x37
go/types.(*Checker).typeDecl(0xc000382a00, 0xc001b0b400, 0xc001219040, 0x0)
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/decl.go:615 +0x44d
go/types.(*Checker).objDecl(0xc000382a00, {0xdae620, 0xc001b0b400}, 0x0)
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/decl.go:197 +0xa7f
go/types.(*Checker).packageObjects(0xc000382a00)
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/resolver.go:681 +0x425
go/types.(*Checker).checkFiles(0xc000382a00, {0xc000c7ec78, 0x3, 0x3})
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/check.go:408 +0x1a5
go/types.(*Checker).Files(...)
/home/linuxbrew/.linuxbrew/Cellar/go/1.22.2/libexec/src/go/types/check.go:372
sigs.k8s.io/controller-tools/pkg/loader.(*loader).typeCheck(0xc000362e40, 0xc0005106e0)
/home/xxx/go/pkg/mod/sigs.k8s.io/controller-tools@v0.9.0/pkg/loader/loader.go:286 +0x36a
sigs.k8s.io/controller-tools/pkg/loader.(*Package).NeedTypesInfo(0xc0005106e0)
/home/xxx/go/pkg/mod/sigs.k8s.io/controller-tools@v0.9.0/pkg/loader/loader.go:99 +0x39
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check(0xc000ae6ed0, 0xc0005106e0)
/home/xxx/go/pkg/mod/sigs.k8s.io/controller-tools@v0.9.0/pkg/loader/refs.go:268 +0x2b7
sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check.func1(0x4a?)
/home/xxx/go/pkg/mod/sigs.k8s.io/controller-tools@v0.9.0/pkg/loader/refs.go:262 +0x53
created by sigs.k8s.io/controller-tools/pkg/loader.(*TypeChecker).check in goroutine 114
/home/xxx/go/pkg/mod/sigs.k8s.io/controller-tools@v0.9.0/pkg/loader/refs.go:260 +0x1c5
make: *** [Makefile:132: generate] Error 2
Previously, no such error occurred.
Is anyone able to provide a minimal repo to reproduce this issue with the latest release?
(alternatively a PR with a fix and unit test which triggers the panic without the fix would also work)
Not necessarily a minimal repo, but the GH actions for https://github.com/sapcc/maintenance-controller/actions/runs/8573915772/job/23499644206 fail consistently with go 1.22.
Using the package in https://github.com/argoproj/argo-cd, when the package (v0.4.1) is installed with 1.22, I get the same error as above.
After switching to go 1.21, performing a go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1
again, everything works as expected.
Have you considered upgrading controller-gen? Current version is now v0.14 (we're close to v0.15).
To be honest, not sure if anyone has time to look into why a release from November 2020 doesn't work with Go 1.22
Is anyone able to provide a minimal repo to reproduce this issue with the latest release?
Is anyone able to provide a minimal repo to reproduce this issue with the latest release (v0.14) :)
I'm going to close this issue in the meantime. Feel free to reopen if we can reproduce it with the latest release.
For folks using older versions I would recommend upgrading :)
/close
@sbueringer: Closing this issue.
I updated to use v0.14 with go 1.22 and it works, but I think it is important to document that using go 1.22 with version < v0.14 will result in the error above.
Makes sense. Not sure if we currently have documentation about supported ct versions in general and which go versions they have been tested with.
But makes sense to have it
Just noting that our finding is that controller-tools 0.13 onwards works with Go 1.22, but 0.12.1 and older fails. We have CAPM3 1.5 release branch now failing with Go 1.22 (using ct 0.12.1), but CAPM3 1.6 with ct 0.13.0 is green. (1.5 is EOS, so no worries)
Error log here: https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_lws/11/pull-lws-test-main/1763464055189671936
This is my command:
CMD
Output(error):
However, if I add
-h
to controller-gen, everything goes well: CMD:Output:
Anyone can provide some advices?
/kind bug /kind support