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

SIGSEGV on refresh state #359

Closed
repomaa opened this issue May 27, 2021 · 4 comments · Fixed by #360
Closed

SIGSEGV on refresh state #359

repomaa opened this issue May 27, 2021 · 4 comments · Fixed by #360

Comments

@repomaa
Copy link

repomaa commented May 27, 2021

I'm encountering following error when refreshing the state for a hcloud project:

 Error: Plugin did not respond
│
│   with hcloud_load_balancer_target.lb_target,
│   on main.tf line 403, in resource "hcloud_load_balancer_target" "lb_target":
│  403: resource "hcloud_load_balancer_target" "lb_target" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more
│ details.
╵

Stack trace from the terraform-provider-hcloud_v1.26.0 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xd22493]

goroutine 256 [running]:
github.com/hetznercloud/terraform-provider-hcloud/internal/certificate.parseCertificates(0xf94f65, 0x24, 0xc000774950, 0x2, 0x2, 0x0, 0x0)
        github.com/hetznercloud/terraform-provider-hcloud/internal/certificate/certdiff.go:64 +0xd3
github.com/hetznercloud/terraform-provider-hcloud/internal/certificate.EqualCert(0xc0004b7b00, 0xd70, 0xf94f65, 0x24, 0xc000240750, 0xc00072f478, 0x4104e5)
        github.com/hetznercloud/terraform-provider-hcloud/internal/certificate/certdiff.go:25 +0x193
github.com/hetznercloud/terraform-provider-hcloud/internal/certificate.UploadedResource.func1(0xf7c2f5, 0xb, 0xc0004b7b00, 0xd70, 0xf94f65, 0x24, 0xc000171a00, 0x203000)
        github.com/hetznercloud/terraform-provider-hcloud/internal/certificate/resource.go:63 +0x50
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.diff(0xc00064e3c0, 0xf7c2f5, 0xb, 0xc0006417c0, 0xc0004d6460, 0x11021e8, 0xc000171a00, 0x0, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.5.0/helper/schema/schema.go:972 +0x383
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.schemaMap.Diff(0xc00064e3c0, 0x10fd5a8, 0xc000777100, 0xc000633d50, 0xc0001ea510, 0x0, 0xea9c40, 0xc000204100, 0x1657100, 0xe04da0, ...)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.5.0/helper/schema/schema.go:522 +0x219
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).SimpleDiff(0xc00026e2a0, 0x10fd5a8, 0xc000777100, 0xc000633d50, 0xc0001ea510, 0xea9c40, 0xc000204100, 0x0, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.5.0/helper/schema/resource.go:506 +0xa5
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).PlanResourceChange(0xc00000d050, 0x10fd5a8, 0xc000777100, 0xc000778f50, 0xc000777100, 0xf30f00, 0xc00070f600)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.5.0/helper/schema/grpc_provider.go:693 +0x7c5
github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).PlanResourceChange(0xc000288100, 0x10fd650, 0xc000777100, 0xc000633c00, 0xc000288100, 0xc00070f650, 0xc000258ba0)
        github.com/hashicorp/terraform-plugin-go@v0.2.1/tfprotov5/server/server.go:315 +0xb5
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_PlanResourceChange_Handler(0xf30f00, 0xc000288100, 0x10fd650, 0xc00070f650, 0xc00007bf20, 0x0, 0x10fd650, 0xc00070f650, 0xc0004c5800, 0x1779)
        github.com/hashicorp/terraform-plugin-go@v0.2.1/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:362 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002f6380, 0x1106638, 0xc0004f4900, 0xc000742100, 0xc000096840, 0x16174e8, 0x0, 0x0, 0x0)
        google.golang.org/grpc@v1.32.0/server.go:1194 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc0002f6380, 0x1106638, 0xc0004f4900, 0xc000742100, 0x0)
        google.golang.org/grpc@v1.32.0/server.go:1517 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc00028a230, 0xc0002f6380, 0x1106638, 0xc0004f4900, 0xc000742100)
        google.golang.org/grpc@v1.32.0/server.go:859 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.32.0/server.go:857 +0x1fd

Error: The terraform-provider-hcloud_v1.26.0 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

What can I do to get past this in the short term? I need to update this infrastructure asap.

@LKaemmerling
Copy link
Member

LKaemmerling commented May 27, 2021

Hey @repomaa,

would it be possible that you provide a minimal reproducible configuration? On the first view, it looks like your certificate is not PEM encoded (or maybe wrong encoded).

The nil pointer will be fixed, to fix this we would need a reproducible config.

@repomaa
Copy link
Author

repomaa commented May 27, 2021

Hm it should be pem encoded, i haven't changed anything and just added a few servers to the setup. Not sure if i can provide a minimal config, as it will mess up the state if i remove resources from it.

@repomaa
Copy link
Author

repomaa commented May 27, 2021

This used to work fine i should add

fhofherr added a commit that referenced this issue May 27, 2021
According to the documentation
[`Decode`](https://pkg.go.dev/encoding/pem#Decode) returns nil if no pem
data is found.

Technically this is possible if the certificate we store in our API did
not contain valid data, or some additional content after the PEM block.
I'm currently not sure how to reproduce this, but this commit should at
least get rid of the panic. Depending on the actual issue it might be
better to return an error instead.

Closes #359
@fhofherr
Copy link
Contributor

Hi, @repomaa I have a preliminary fix in the works. But I'm unsure how to reproduce and subsequently test it. Could you send me the name of the affected project and your customer number to ferdinand.hofherr@hetzner-cloud.de?

I guess you know this, but I have to write it anyways: please don't include any sensitive information like private keys or passwords.

fhofherr added a commit that referenced this issue May 28, 2021
According to the documentation
[`Decode`](https://pkg.go.dev/encoding/pem#Decode) returns nil if no pem
data is found.

This is possible if the certificate contains additional data which is
not part of the certificate. If this data occurs at the end the code
before this commit panics. This commit ensures that such data is
ignored. Data between two certificates in the chain is ignored as well.
Leading data leads to an error being returned.

Closes #359
fhofherr added a commit that referenced this issue May 28, 2021
According to the documentation
[`Decode`](https://pkg.go.dev/encoding/pem#Decode) returns nil if no pem
data is found.

This is possible if the certificate contains additional data which is
not part of the certificate. If this data occurs at the end the code
before this commit panics. This commit ensures that such data is
ignored. Data between two certificates in the chain is ignored as well.
Leading data leads to an error being returned.

Closes #359
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.

3 participants