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 crashes(invalid memory address) if there's a .tf file in json format #8295

Closed
kjkuan opened this issue Aug 18, 2016 · 2 comments · Fixed by hashicorp/hcl#143
Closed
Assignees

Comments

@kjkuan
Copy link

kjkuan commented Aug 18, 2016

To reproduce, create a crash.tf file with the following contents:

{
  "variable": {
    "whatever": "abc123"
  }
}

Then run terraform plan from the same directory, and it will crash with a log that looks like the following:

2016/08/18 14:57:22 [INFO] Terraform version: 0.7.0  e822a79165dbc06bbf8271ee349fe256867d53dc
2016/08/18 14:57:22 [DEBUG] Detected home directory from env var: /Users/jkuan
2016/08/18 14:57:22 [DEBUG] Detected home directory from env var: /Users/jkuan
2016/08/18 14:57:22 [DEBUG] Attempting to open CLI config file: /Users/jkuan/.terraformrc
2016/08/18 14:57:22 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2016/08/18 14:57:22 [DEBUG] Detected home directory from env var: /Users/jkuan
2016/08/18 14:57:22 [DEBUG] plugin: waiting for all plugin processes to complete...
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x8 pc=0xb3d60a]

goroutine 1 [running]:
panic(0x2fb1ba0, 0x8262f60d0)
        /opt/go/src/runtime/panic.go:481 +0x3e6
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl/hcl/ast.(*ObjectList).Filter(0x82661d620, 0x82641d450, 0x1, 0x1, 0x2)
        /opt/gopath/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl/hcl/ast/ast.go:59 +0xaa
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl.(*decoder).decodeStruct(0x82641ee68, 0x82661d5e0, 0x16, 0x882637beb0, 0x82661d620, 0x32952c0, 0x826611c70, 0x199, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl/decoder.go:608 +0x1dfb
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl.(*decoder).decode(0x82641ee68, 0x82661d5e0, 0x16, 0x882637bfb0, 0x826611c20, 0x32952c0, 0x826611c70, 0x199, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl/decoder.go:108 +0x9a4
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl.(*decoder).decodePtr(0x82641ee68, 0x82661d5e0, 0x16, 0x882637bfb0, 0x826611c20, 0x253fd60, 0x8264942b0, 0x196, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl/decoder.go:397 +0x151
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl.(*decoder).decode(0x82641ee68, 0x82661d5e0, 0x16, 0x882637bfb0, 0x826611c20, 0x253fd60, 0x8264942b0, 0x196, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl/decoder.go:102 +0x862
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl.(*decoder).decodeMap(0x82641ee68, 0x82663e450, 0xd, 0x882637beb0, 0x82661d5c0, 0x2668d60, 0x826494298, 0x195, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl/decoder.go:378 +0x14c5
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl.(*decoder).decode(0x82641ee68, 0x82663e450, 0xd, 0x882637beb0, 0x82661d5c0, 0x2668d60, 0x826494298, 0x195, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl/decoder.go:100 +0x7f4
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl.(*decoder).decodeStruct(0x82641ee68, 0x37cff48, 0x4, 0x882637beb0, 0x82661d4e0, 0x26a60e0, 0x826494298, 0x199, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl/decoder.go:632 +0x2355
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl.(*decoder).decode(0x82641ee68, 0x37cff48, 0x4, 0x882637beb0, 0x82661d4e0, 0x26a60e0, 0x826494298, 0x199, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl/decoder.go:108 +0x9a4
github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl.DecodeObject(0x25f8620, 0x826494298, 0x882637beb0, 0x82661d4e0, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/vendor/github.com/hashicorp/hcl/decoder.go:60 +0x25f
github.com/hashicorp/terraform/config.(*hclConfigurable).Config(0x82661d520, 0x37c23b8, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/config/loader_hcl.go:48 +0x3af
github.com/hashicorp/terraform/config.(*importTree).ConfigTree(0x826617800, 0x4c, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/config/import_tree.go:87 +0x68
github.com/hashicorp/terraform/config.LoadFile(0x8266111d0, 0x4c, 0x8264e2420, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/config/loader.go:44 +0x80
github.com/hashicorp/terraform/config.LoadDir(0x8262f80a4, 0x43, 0x11, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/config/loader.go:91 +0x38c
github.com/hashicorp/terraform/config/module.NewTreeModule(0x0, 0x0, 0x8262f80a4, 0x43, 0x0, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/config/module/tree.go:54 +0x41
github.com/hashicorp/terraform/command.(*Meta).Context(0x8265042d0, 0x8262f80a4, 0x43, 0x7fff5fbfea45, 0x24, 0x0, 0xa, 0x4, 0x6, 0x0, ...)
        /opt/gopath/src/github.com/hashicorp/terraform/command/meta.go:155 +0x54a
github.com/hashicorp/terraform/command.(*PlanCommand).Run(0x8265042d0, 0x8262ec570, 0x0, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/command/plan.go:65 +0x7b7
github.com/hashicorp/terraform/vendor/github.com/mitchellh/cli.(*CLI).Run(0x8264d2840, 0x8265075c0, 0x0, 0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/vendor/github.com/mitchellh/cli/cli.go:153 +0x56e
main.wrappedMain(0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/main.go:144 +0xaf9
main.realMain(0x0)
        /opt/gopath/src/github.com/hashicorp/terraform/main.go:80 +0xa10
main.main()
        /opt/gopath/src/github.com/hashicorp/terraform/main.go:23 +0x28

@mitchellh
Copy link
Contributor

Fixed in PR on hcl: hashicorp/hcl#143

mitchellh added a commit that referenced this issue Aug 22, 2016
mitchellh added a commit that referenced this issue Aug 22, 2016
@ghost
Copy link

ghost commented Apr 23, 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 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.

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

Successfully merging a pull request may close this issue.

3 participants