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

Terraform Crash #32186

Closed
nus1712 opened this issue Nov 8, 2022 · 12 comments · Fixed by #32207
Closed

Terraform Crash #32186

nus1712 opened this issue Nov 8, 2022 · 12 comments · Fixed by #32207
Assignees
Labels
bug confirmed a Terraform Core team member has reproduced this issue

Comments

@nus1712
Copy link

nus1712 commented Nov 8, 2022

Terraform Version

Terraform Cloud 1.3.4

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

attempt to write nil state to file
goroutine 71 [running]:
runtime/debug.Stack()
        /usr/local/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
        /usr/local/go/src/runtime/debug/stack.go:16 +0x19
github.com/hashicorp/terraform/internal/logging.PanicHandler()
        /home/circleci/project/project/internal/logging/panic.go:55 +0x153
panic({0x2143f40, 0x2b43210})
        /usr/local/go/src/runtime/panic.go:884 +0x212
github.com/hashicorp/terraform/internal/states/statefile.writeStateV4(0xc00310ba8c?, {0x2b46420?, 0xc003fdf360?})
        /home/circleci/project/project/internal/states/statefile/version4.go:322 +0x15f8
github.com/hashicorp/terraform/internal/states/statefile.Write(0xc00310bc50?, {0x2b46420?, 0xc003fdf360?})
        /home/circleci/project/project/internal/states/statefile/write.go:15 +0x45
github.com/hashicorp/terraform/internal/plans/planfile.Create({0x7f14d63db020?, 0x60?}, {0xc000128330, 0xc00310be30, 0xc0031d5950, 0xc004f6d1e0, 0xc0007508b8})
        /home/circleci/project/project/internal/plans/planfile/writer.go:103 +0x670
github.com/hashicorp/terraform/internal/backend/local.(*Local).opPlan(0xc00030be00, {0x2b6adb8, 0xc0008c5d80}, {0x2b6adb8, 0xc0008c5dc0}, 0xc0004fb440, 0xc0008c5d40)
        /home/circleci/project/project/internal/backend/local/backend_plan.go:138 +0x905
github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation.func1()
        /home/circleci/project/project/internal/backend/local/backend.go:323 +0xc3
created by github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation
        /home/circleci/project/project/internal/backend/local/backend.go:316 +0x44a
Operation failed: failed running terraform plan (exit 11)

Terraform Configuration Files

was trying to run terraform destroy

Debug Output

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

attempt to write nil state to file
goroutine 71 [running]:
runtime/debug.Stack()
/usr/local/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
/usr/local/go/src/runtime/debug/stack.go:16 +0x19
github.com/hashicorp/terraform/internal/logging.PanicHandler()
/home/circleci/project/project/internal/logging/panic.go:55 +0x153
panic({0x2143f40, 0x2b43210})
/usr/local/go/src/runtime/panic.go:884 +0x212
github.com/hashicorp/terraform/internal/states/statefile.writeStateV4(0xc00310ba8c?, {0x2b46420?, 0xc003fdf360?})
/home/circleci/project/project/internal/states/statefile/version4.go:322 +0x15f8
github.com/hashicorp/terraform/internal/states/statefile.Write(0xc00310bc50?, {0x2b46420?, 0xc003fdf360?})
/home/circleci/project/project/internal/states/statefile/write.go:15 +0x45
github.com/hashicorp/terraform/internal/plans/planfile.Create({0x7f14d63db020?, 0x60?}, {0xc000128330, 0xc00310be30, 0xc0031d5950, 0xc004f6d1e0, 0xc0007508b8})
/home/circleci/project/project/internal/plans/planfile/writer.go:103 +0x670
github.com/hashicorp/terraform/internal/backend/local.(*Local).opPlan(0xc00030be00, {0x2b6adb8, 0xc0008c5d80}, {0x2b6adb8, 0xc0008c5dc0}, 0xc0004fb440, 0xc0008c5d40)
/home/circleci/project/project/internal/backend/local/backend_plan.go:138 +0x905
github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation.func1()
/home/circleci/project/project/internal/backend/local/backend.go:323 +0xc3
created by github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation
/home/circleci/project/project/internal/backend/local/backend.go:316 +0x44a
Operation failed: failed running terraform plan (exit 11)

Expected Behavior

should run command successfully and destroy resources

Actual Behavior

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

attempt to write nil state to file
goroutine 71 [running]:
runtime/debug.Stack()
/usr/local/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
/usr/local/go/src/runtime/debug/stack.go:16 +0x19
github.com/hashicorp/terraform/internal/logging.PanicHandler()
/home/circleci/project/project/internal/logging/panic.go:55 +0x153
panic({0x2143f40, 0x2b43210})
/usr/local/go/src/runtime/panic.go:884 +0x212
github.com/hashicorp/terraform/internal/states/statefile.writeStateV4(0xc00310ba8c?, {0x2b46420?, 0xc003fdf360?})
/home/circleci/project/project/internal/states/statefile/version4.go:322 +0x15f8
github.com/hashicorp/terraform/internal/states/statefile.Write(0xc00310bc50?, {0x2b46420?, 0xc003fdf360?})
/home/circleci/project/project/internal/states/statefile/write.go:15 +0x45
github.com/hashicorp/terraform/internal/plans/planfile.Create({0x7f14d63db020?, 0x60?}, {0xc000128330, 0xc00310be30, 0xc0031d5950, 0xc004f6d1e0, 0xc0007508b8})
/home/circleci/project/project/internal/plans/planfile/writer.go:103 +0x670
github.com/hashicorp/terraform/internal/backend/local.(*Local).opPlan(0xc00030be00, {0x2b6adb8, 0xc0008c5d80}, {0x2b6adb8, 0xc0008c5dc0}, 0xc0004fb440, 0xc0008c5d40)
/home/circleci/project/project/internal/backend/local/backend_plan.go:138 +0x905
github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation.func1()
/home/circleci/project/project/internal/backend/local/backend.go:323 +0xc3
created by github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation
/home/circleci/project/project/internal/backend/local/backend.go:316 +0x44a
Operation failed: failed running terraform plan (exit 11)

Steps to Reproduce

terraform destroy

Additional Context

No response

References

No response

@nus1712 nus1712 added bug new new issue not yet triaged labels Nov 8, 2022
@keelerad
Copy link

keelerad commented Nov 9, 2022

I have also seen this behaviour with terraform v1.3.4 using the Linux binary download https://releases.hashicorp.com/terraform/1.3.4/terraform_1.3.4_linux_amd64.zip

This was after doing a change of version for the azurerm provider and was run in a docker image in a jenkins pipeline

  • terraform plan -destroy -input=false -out=/tmp/decrypted_secrets/tf.plan -var-file=/var/lib/jenkins/workspace/perform-a-manual-upgrade-of-the-/tf/configuration/terraform.tfvars

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.
[1]: https://github.com/hashicorp/terraform/issues
!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
attempt to write nil state to file
goroutine 28 [running]:
runtime/debug.Stack()
/usr/local/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
/usr/local/go/src/runtime/debug/stack.go:16 +0x19
github.com/hashicorp/terraform/internal/logging.PanicHandler()
/home/circleci/project/project/internal/logging/panic.go:55 +0x153
panic({0x2143f40, 0x2b43210})
/usr/local/go/src/runtime/panic.go:884 +0x212
github.com/hashicorp/terraform/internal/states/statefile.writeStateV4(0xc0005bba8c?, {0x2b46420?, 0xc001c1f4a0?})
/home/circleci/project/project/internal/states/statefile/version4.go:322 +0x15f8
github.com/hashicorp/terraform/internal/states/statefile.Write(0xc0005bbc50?, {0x2b46420?, 0xc001c1f4a0?})
/home/circleci/project/project/internal/states/statefile/write.go:15 +0x45
github.com/hashicorp/terraform/internal/plans/planfile.Create({0x7ffca0b2016a?, 0x1e?}, {0xc000012200, 0xc0005bbe30, 0xc001b00570, 0xc0009f85b0, 0xc0003bd368})
/home/circleci/project/project/internal/plans/planfile/writer.go:103 +0x670
github.com/hashicorp/terraform/internal/backend/local.(*Local).opPlan(0xc0001b8820, {0x2b6adb8, 0xc0007eef00}, {0x2b6adb8, 0xc0007eef40}, 0xc0007987e0, 0xc0007eeec0)
/home/circleci/project/project/internal/backend/local/backend_plan.go:138 +0x905
github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation.func1()
/home/circleci/project/project/internal/backend/local/backend.go:323 +0xc3
created by github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation
/home/circleci/project/project/internal/backend/local/backend.go:316 +0x44a
script returned exit code 11

@jbardin jbardin added confirmed a Terraform Core team member has reproduced this issue and removed new new issue not yet triaged labels Nov 9, 2022
@jbardin jbardin self-assigned this Nov 9, 2022
@nolehusker
Copy link

I too have this issue. Ouptut
!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
attempt to write nil state to file
goroutine 54 [running]:
runtime/debug.Stack()
/usr/local/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
/usr/local/go/src/runtime/debug/stack.go:16 +0x19
github.com/hashicorp/terraform/internal/logging.PanicHandler()
/home/circleci/project/project/internal/logging/panic.go:55 +0x153
panic({0x2143f40, 0x2b43210})
/usr/local/go/src/runtime/panic.go:884 +0x212
github.com/hashicorp/terraform/internal/states/statefile.writeStateV4(0xc002b55a8c?, {0x2b46420?, 0xc002b324b0?})
/home/circleci/project/project/internal/states/statefile/version4.go:322 +0x15f8
github.com/hashicorp/terraform/internal/states/statefile.Write(0xc002b55c50?, {0x2b46420?, 0xc002b324b0?})
/home/circleci/project/project/internal/states/statefile/write.go:15 +0x45
github.com/hashicorp/terraform/internal/plans/planfile.Create({0x7ffedd65cf46?, 0x8?}, {0xc00016e350, 0xc002b55e30, 0xc0031c0a20, 0xc004e8bc70, 0xc000cc4af8})
/home/circleci/project/project/internal/plans/planfile/writer.go:103 +0x670
github.com/hashicorp/terraform/internal/backend/local.(*Local).opPlan(0xc000c84b40, {0x2b6adb8, 0xc000939940}, {0x2b6adb8, 0xc000939980}, 0xc00034e360, 0xc000939900)
/home/circleci/project/project/internal/backend/local/backend_plan.go:138 +0x905
github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation.func1()
/home/circleci/project/project/internal/backend/local/backend.go:323 +0xc3
created by github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation
/home/circleci/project/project/internal/backend/local/backend.go:316 +0x44a

@FranPavelic-SB
Copy link

Hit this one as well with 1.3.4 on linux...


!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

attempt to write nil state to file
goroutine 10 [running]:
runtime/debug.Stack()
	/usr/local/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
	/usr/local/go/src/runtime/debug/stack.go:16 +0x19
github.com/hashicorp/terraform/internal/logging.PanicHandler()
	/home/circleci/project/project/internal/logging/panic.go:55 +0x153
panic({0x2143f40, 0x2b43210})
	/usr/local/go/src/runtime/panic.go:884 +0x212
github.com/hashicorp/terraform/internal/states/statefile.writeStateV4(0xc001befa8c?, {0x2b46420?, 0xc002d43270?})
	/home/circleci/project/project/internal/states/statefile/version4.go:322 +0x15f8
github.com/hashicorp/terraform/internal/states/statefile.Write(0xc001befc50?, {0x2b46420?, 0xc002d43270?})
	/home/circleci/project/project/internal/states/statefile/write.go:15 +0x45
github.com/hashicorp/terraform/internal/plans/planfile.Create({0x7ffed382b775?, 0xf?}, {0xc000522768, 0xc001befe30, 0xc002fb1740, 0xc003583ad0, 0xc000af0180})
	/home/circleci/project/project/internal/plans/planfile/writer.go:103 +0x670
github.com/hashicorp/terraform/internal/backend/local.(*Local).opPlan(0xc000b24aa0, {0x2b6adb8, 0xc0006ce1c0}, {0x2b6adb8, 0xc0006ce200}, 0xc000720c60, 0xc0006ce140)
	/home/circleci/project/project/internal/backend/local/backend_plan.go:138 +0x905
github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation.func1()
	/home/circleci/project/project/internal/backend/local/backend.go:323 +0xc3
created by github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation
	/home/circleci/project/project/internal/backend/local/backend.go:[316] +0x44a

@RustedBl4de
Copy link

This just started for us today using Gitlab with gitlab-runner 15.5.0 (0d4137b8).

We are dead in the water.

@kichitan
Copy link

I just ran into it, now. I was able to destroy one of my environments and when I try to destroy another one these error pop.

Terraform v1.3.4
on linux_amd64

Using the mac version.

Also I notice that if I destroy some of my objects manually and then run a plan, terraform won't notice any changes in the state.

@kichitan
Copy link

Ok, in my case. I was pointing my backend to the wrong state file, once I make the changed it worked fine

@RustedBl4de
Copy link

I have confirmed that the state file being used, Gitlab Managed, is not the cause. I removed the existing state file and it was recreated but still caused the original crash.

@halx4
Copy link

halx4 commented Nov 17, 2022

For us this appeared when trying to store the output plan of "terraform plan -destroy" on a module with empty state file
Here is a minimal example to reproduce:

  • create a main.tf with this content:
provider "aws" {
  region = "eu-west-1"
}


resource "aws_security_group" "web" {
  name="testsgf"

}
  • apply the module: terraform apply
  • destroy the module: terraform apply -destroy
  • try to export the destroy plan on a file: terraform plan -destroy -out=outfile
    At this point terraform crashes with a stacktrace:
$ terraform plan -destroy -out=outfile

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

attempt to write nil state to file
goroutine 23 [running]:
runtime/debug.Stack()
        /usr/local/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
        /usr/local/go/src/runtime/debug/stack.go:16 +0x19
github.com/hashicorp/terraform/internal/logging.PanicHandler()
        /home/circleci/project/project/internal/logging/panic.go:55 +0x153
panic({0x2fc4540, 0x39d66c0})
        /usr/local/go/src/runtime/panic.go:884 +0x212
github.com/hashicorp/terraform/internal/states/statefile.writeStateV4(0xc000b19a8c?, {0x39d9960?, 0xc0060d2b40?})
        /home/circleci/project/project/internal/states/statefile/version4.go:322 +0x15f8
github.com/hashicorp/terraform/internal/states/statefile.Write(0xc000b19c50?, {0x39d9960?, 0xc0060d2b40?})
        /home/circleci/project/project/internal/states/statefile/write.go:15 +0x45
github.com/hashicorp/terraform/internal/plans/planfile.Create({0xc00004a0f5?, 0x7?}, {0xc000702250, 0xc000b19e30, 0xc001ef5c50, 0xc0047d29c0, 0xc0007a0078})
        /home/circleci/project/project/internal/plans/planfile/writer.go:103 +0x670
github.com/hashicorp/terraform/internal/backend/local.(*Local).opPlan(0xc00013b7c0, {0x39fe2f8, 0xc0006f3040}, {0x39fe2f8, 0xc0006f3080}, 0xc000348fc0, 0xc0006f3000)
        /home/circleci/project/project/internal/backend/local/backend_plan.go:138 +0x905
github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation.func1()
        /home/circleci/project/project/internal/backend/local/backend.go:323 +0xc3
created by github.com/hashicorp/terraform/internal/backend/local.(*Local).Operation
        /home/circleci/project/project/internal/backend/local/backend.go:316 +0x44a

whereas it was expected to export an empty plan in the relevant file.

@RustedBl4de
Copy link

@jbardin Sorry to be a stickler... but shouldn't we confirm that this resolves the reported issue for the users?

@jbardin
Copy link
Member

jbardin commented Nov 17, 2022

@RustedBl4de, issues are closed by GitHub automatically upon merging the associated PR into the development branch. The issue can be re-opened or new issues filed if the next release does not address the problem.

@RustedBl4de
Copy link

Thanks for the response and all the work!!

@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 Dec 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug confirmed a Terraform Core team member has reproduced this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants