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

provider: ensuring the providers slice isn't a nil pointer #5113

Merged
merged 1 commit into from
Dec 9, 2019

Conversation

tombuildsstuff
Copy link
Contributor

This was a fun one to track down.

Turns out due to the way that parallelization works, init() gets called after
the resource.ParallelTest has been called - which means that testAccProviders
could be an empty slice, which caused an unhelpful crash in the Plugin SDK.

Before this change:

2019/12/09 07:55:18 [TRACE] LoadSchemas: retrieving schema for provider type "azurerm"
2019/12/09 07:55:18 [TRACE] GRPCProvider: GetSchema
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x2725f14]
goroutine 25 [running]:
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).getProviderSchemaBlock(...)
	/Users/tharvey/code/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.1.1/internal/helper/plugin/grpc_provider.go:76
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).GetSchema(0xc0000b71f8, 0x5aace60, 0xc00094c300, 0xc000548ee0, 0xc0000b71f8, 0xc00094c300, 0xc000074a80)
	/Users/tharvey/code/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.1.1/internal/helper/plugin/grpc_provider.go:55 +0x94
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_GetSchema_Handler(0x4dfec00, 0xc0000b71f8, 0x5aace60, 0xc00094c300, 0xc0009520c0, 0x0, 0x5aace60, 0xc00094c300, 0x0, 0x0)
	/Users/tharvey/code/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.1.1/internal/tfplugin5/tfplugin5.pb.go:3045 +0x217
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000fa2c0, 0x5b073c0, 0xc00088c300, 0xc00097e000, 0xc000727e30, 0x8736660, 0x0, 0x0, 0x0)
	/Users/tharvey/code/pkg/mod/google.golang.org/grpc@v1.23.0/server.go:995 +0x460
google.golang.org/grpc.(*Server).handleStream(0xc0000fa2c0, 0x5b073c0, 0xc00088c300, 0xc00097e000, 0x0)
	/Users/tharvey/code/pkg/mod/google.golang.org/grpc@v1.23.0/server.go:1275 +0xd97
google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0004a83e0, 0xc0000fa2c0, 0x5b073c0, 0xc00088c300, 0xc00097e000)
	/Users/tharvey/code/pkg/mod/google.golang.org/grpc@v1.23.0/server.go:710 +0xbb
created by google.golang.org/grpc.(*Server).serveStreams.func1
	/Users/tharvey/code/pkg/mod/google.golang.org/grpc@v1.23.0/server.go:708 +0xa1
FAIL	github.com/terraform-providers/terraform-provider-azurerm/azurerm	0.050s
FAIL

Tests pass:

$ acctests azurerm TestAccAzureRMResourceGroup_basic
=== RUN   TestAccAzureRMResourceGroup_basic
=== PAUSE TestAccAzureRMResourceGroup_basic
=== CONT  TestAccAzureRMResourceGroup_basic
--- PASS: TestAccAzureRMResourceGroup_basic (77.08s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm	77.132s

This was a fun one to track down.

Turns out due to the way that parallelization works, `init()` gets called after
the `resource.ParallelTest` has been called - which means that `testAccProviders`
could be an empty slice, which caused an unhelpful crash in the Plugin SDK.
@tombuildsstuff tombuildsstuff added this to the v1.39.0 milestone Dec 9, 2019
@tombuildsstuff tombuildsstuff requested a review from a team December 9, 2019 19:18
@ghost ghost added the size/XS label Dec 9, 2019
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@ghost
Copy link

ghost commented Dec 16, 2019

This has been released in version 1.39.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 1.39.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Jan 9, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants