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

segfault when using gcs repository #909

Closed
gboor opened this issue Jul 4, 2024 · 0 comments · Fixed by #914
Closed

segfault when using gcs repository #909

gboor opened this issue Jul 4, 2024 · 0 comments · Fixed by #914

Comments

@gboor
Copy link

gboor commented Jul 4, 2024

I have a state file that worked fine until I added a gs:// repository. Now when I run apply, I get a segfault;

2024-07-04 14:48:01 INFO: Setting up helm
2024-07-04 14:48:01 INFO: Listing helm repositories
2024-07-04 14:48:01 INFO: Checking Helm version
2024-07-04 14:48:01 INFO: Validating that [ gcs ] is installed
2024-07-04 14:48:02 INFO: Cleaning up sensitive and temp files
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0xacfeec]

goroutine 1 [running]:
github.com/Praqma/helmsman/internal/gcs.IsRunningInGCP()
        github.com/Praqma/helmsman/internal/gcs/gcs.go:21 +0x2c
github.com/Praqma/helmsman/internal/gcs.Auth()
        github.com/Praqma/helmsman/internal/gcs/gcs.go:47 +0x128
github.com/Praqma/helmsman/internal/app.addHelmRepos(0xc0007265d0)
        github.com/Praqma/helmsman/internal/app/helm_helpers.go:211 +0x76a
github.com/Praqma/helmsman/internal/app.Main()
        github.com/Praqma/helmsman/internal/app/main.go:76 +0x2f6
main.main()
        github.com/Praqma/helmsman/cmd/helmsman/main.go:9 +0x19

This points to this function - and specifically the resp.Body.Close() line;

func IsRunningInGCP() bool {
	resp, err := http.Get("http://metadata.google.internal")
	resp.Body.Close()
	return err == nil
}

My suspicion is that the resp.Body is actually nil, since the URL cannot be resolved. From the go http docs;

When err is nil, resp always contains a non-nil resp.Body. Caller should close resp.Body when done reading from it.

From that I read that if err is not nil, the resp.Body may be nil.

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.

1 participant