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

[CRITICAL][v2.8.0] Data resources cause provider segmentation fault on new state #813

Closed
nfx opened this issue Oct 11, 2021 · 2 comments · Fixed by #815
Closed

[CRITICAL][v2.8.0] Data resources cause provider segmentation fault on new state #813

nfx opened this issue Oct 11, 2021 · 2 comments · Fixed by #815
Assignees
Labels
bug Something isn't working
Milestone

Comments

@nfx
Copy link

nfx commented Oct 11, 2021

SDK version

SDK v2.8.0 crashes provider data resources: databricks/terraform-provider-databricks#854

Logs say: Instance Diff is nil in Diff(), which is a valid case for starting new terraform state:

        if instanceDiff != nil {
		if err := t.DiffEncode(instanceDiff); err != nil {
			log.Printf("[ERR] Error encoding timeout to instance diff: %s", err)
		}
	} else {
		log.Printf("[DEBUG] Instance Diff is nil in Diff()")
	}

	return instanceDiff, err

Closer inspection of SDK updates - v2.7.0...v2.8.0 - show, that diff.RawConfig = configVal was added without a wrapping nil check.

Terraform Configuration Files

terraform {
  required_providers {
    databricks = {
      source  = "databrickslabs/databricks"
      version = "0.3.8"
    }
  }
}

provider "databricks" {
  host  = "https://XXX.cloud.databricks.com/"
  token = "YYY"
}

data "databricks_node_type" "smallest" {
}

Debug Output

[WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/databrickslabs/databricks\"]" changed the config value, but that value is unused
[INFO]  provider.terraform-provider-databricks: Explicit and implicit attributes: host, token: timestamp=2021-10-11T11:53:57.183+0200
[DEBUG] Resource instance state not found for node "data.databricks_node_type.smallest", instance data.databricks_node_type.smallest
[DEBUG] ReferenceTransformer: "data.databricks_node_type.smallest" references: []
[DEBUG] provider.terraform-provider-databricks: Instance Diff is nil in Diff(): timestamp=2021-10-11T11:53:57.185+0200
[DEBUG] provider.terraform-provider-databricks: PANIC: runtime error: invalid memory address or nil pointer dereference
[DEBUG] provider.terraform-provider-databricks: [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1625584]
2021-10-11T11:53:57.187+0200 [DEBUG] provider.terraform-provider-databricks:
2021-10-11T11:53:57.187+0200 [DEBUG] provider.terraform-provider-databricks: goroutine 71 [running]:
2021-10-11T11:53:57.187+0200 [DEBUG] provider.terraform-provider-databricks: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0xc00054c930, {0x1d87d48, 0xc00053dac0}, 0xc0002d3a00)
2021-10-11T11:53:57.187+0200 [DEBUG] provider.terraform-provider-databricks: 	.../vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/grpc_provider.go:1126 +0x304

Expected Behavior

  • Any version of SDK must not get released with segfaults in happy flow.
  • github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource/testing.go should catch errors on acceptance test level. SDK v2.8.0 does not give the ability to detect such errors.

Actual Behavior

 Error: Plugin did not respond
│
│   with data.databricks_node_type.smallest,
│   on main.tf line 15, in data "databricks_node_type" "smallest":
│   15: data "databricks_node_type" "smallest" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadDataSource call. The plugin logs may contain more details.

Steps to Reproduce

terraform init && terraform plan

References

@nfx nfx added the bug Something isn't working label Oct 11, 2021
@bflad bflad self-assigned this Oct 12, 2021
@bflad
Copy link
Contributor

bflad commented Oct 12, 2021

Hi @nfx 👋 Thank you for raising this and sorry you ran into trouble. I was able to create covering testing for this situation and will submit the fix shortly.

bflad added a commit that referenced this issue Oct 12, 2021
Reference: #813

Previously:

```
    --- FAIL: TestReadDataSource/optional-no-id (0.00s)
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=0x18 pc=0x12f3f64]

goroutine 20 [running]:
testing.tRunner.func1.2({0x1418300, 0x17d34d0})
        /usr/local/Cellar/go/1.17.1/libexec/src/testing/testing.go:1209 +0x24e
testing.tRunner.func1()
        /usr/local/Cellar/go/1.17.1/libexec/src/testing/testing.go:1212 +0x218
panic({0x1418300, 0x17d34d0})
        /usr/local/Cellar/go/1.17.1/libexec/src/runtime/panic.go:1038 +0x215
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0xc00013ce58, {0x1583cb0, 0xc000128008}, 0xc0001626a0)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/grpc_provider.go:1126 +0x304
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.TestReadDataSource.func9(0xc0002124e0)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/grpc_provider_test.go:1381 +0x6b
```
@bflad bflad added this to the v2.8.1 milestone Oct 12, 2021
bflad added a commit that referenced this issue Oct 14, 2021
Reference: #813

Previously:

```
    --- FAIL: TestReadDataSource/optional-no-id (0.00s)
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=0x18 pc=0x12f3f64]

goroutine 20 [running]:
testing.tRunner.func1.2({0x1418300, 0x17d34d0})
        /usr/local/Cellar/go/1.17.1/libexec/src/testing/testing.go:1209 +0x24e
testing.tRunner.func1()
        /usr/local/Cellar/go/1.17.1/libexec/src/testing/testing.go:1212 +0x218
panic({0x1418300, 0x17d34d0})
        /usr/local/Cellar/go/1.17.1/libexec/src/runtime/panic.go:1038 +0x215
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0xc00013ce58, {0x1583cb0, 0xc000128008}, 0xc0001626a0)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/grpc_provider.go:1126 +0x304
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.TestReadDataSource.func9(0xc0002124e0)
        /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/schema/grpc_provider_test.go:1381 +0x6b
```
@bflad bflad modified the milestones: v2.8.1, v2.9.0 Oct 14, 2021
@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
2 participants