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

panic: runtime error: invalid memory address or nil pointer dereference #624

Closed
cscetbon opened this issue Sep 26, 2021 · 6 comments
Closed
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@cscetbon
Copy link

Using controller-ben v0.6.2 I get a panic error when trying to generate the crd for https://github.com/Orange-OpenSource/casskop/tree/fix-crds/multi-casskop

controller-gen --version
Version: v0.6.2
make controller-gen
make[1]: Entering directory '/home/circleci/*******/multi-*******'
Makefile:102: warning: overriding recipe for target 'build'
../shared.mk:127: warning: ignoring old recipe for target 'build'
make[1]: Nothing to be done for 'controller-gen'.
make[1]: Leaving directory '/home/circleci/*******/multi-*******'
/go/bin/controller-gen crd paths=./pkg/apis/... output:dir=./deploy/crds schemapatch:manifests=./deploy/crds
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xa15efb]

goroutine 1 [running]:
sigs.k8s.io/controller-tools/pkg/crd.schemaWalker.walkSchema({{0xcdc240, 0xc004cac1e0}}, 0x0)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema_visitor.go:63 +0xbb
sigs.k8s.io/controller-tools/pkg/crd.EditSchema(...)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/schema_visitor.go:42
sigs.k8s.io/controller-tools/pkg/crd.FlattenEmbedded(0xc0021048d0, {0xcdc280, 0xc0000ede00})
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/flatten.go:210 +0x7b
sigs.k8s.io/controller-tools/pkg/crd.(*Parser).NeedFlattenedSchemaFor(0xc003649ce0, {0xc0000ede00, {0xc0004fa070, 0x2}})
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/crd/parser.go:204 +0xe8
sigs.k8s.io/controller-tools/pkg/schemapatcher.Generator.Generate({{0xc0001c293a, 0xb43d80}, 0x0, 0x0}, 0xc001c2f7c0)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/schemapatcher/gen.go:143 +0x9e9
sigs.k8s.io/controller-tools/pkg/genall.(*Runtime).Run(0xc00024ca00)
	/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/genall/genall.go:207 +0x206
main.main.func1(0xc0002b8500, {0xc00028dc00, 0x4, 0x4})
	/go/pkg/mod/sigs.k8s.io/[email protected]/cmd/controller-gen/main.go:176 +0x6a
github.com/spf13/cobra.(*Command).execute(0xc0002b8500, {0xc00019e010, 0x4, 0x4})
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc0002b8500)
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
main.main()
	/go/pkg/mod/sigs.k8s.io/[email protected]/cmd/controller-gen/main.go:200 +0x2c6
make: *** [../shared.mk:122: generate] Error 2

I'm trying to replace operator-sdk generate k8s by using controller-gen but hit this error.

@cscetbon
Copy link
Author

same with version 0.7.0

@abayer
Copy link

abayer commented Sep 29, 2021

I hit this same panic/stack trace, though in a bit of a different scenario than I saw in your repo - in Tekton Pipelines, we have pkg/apis/pipeline/{v1alpha1,v1beta1}, pkg/apis/resource/v1alpha1, and pkg/apis/run/v1alpha1, all with the same tekton.devgroup. I did some debugging and discovered that it would fail trying to find a kind from, say,pkg/apis/run/v1alpha1in the packagepkg/apis/resource/v1alpha1`. I've got a bare fix up at abayer@c8009f3, and will try to open a PR once I've gotten a test case set up.

abayer added a commit to abayer/controller-tools that referenced this issue Sep 29, 2021
I hit this problem with cases where there are multiple packages with the same group and version. The schema patcher would hit a nil pointer trying to flatten a schema for a kind that exists in one package, but not another, because it seems to assume that everything's in one package. By skipping cases where the parser hasn't already found the given kind in the given package, we got past that panic and everything works correctly.

I believe this fixes kubernetes-sigs#624, though I can't be sure if this is the only path that can lead to that panic.

Signed-off-by: Andrew Bayer <[email protected]>
abayer added a commit to abayer/controller-tools that referenced this issue Sep 29, 2021
I hit this problem with cases where there are multiple packages with the
same group and version. The schema patcher would hit a nil pointer
trying to flatten a schema for a kind that exists in one package, but
not another, because it seems to assume that everything's in one
package. By skipping cases where the parser hasn't already found the
given kind in the given package, we got past that panic and everything
works correctly.

I believe this should address kubernetes-sigs#624, though I can't be sure if this is
the only path that can lead to that panic.

Signed-off-by: Andrew Bayer <[email protected]>
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 28, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 27, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closing this issue.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants