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

Packer with HCL crashes on missing variable default. #8730

Closed
phaer opened this issue Feb 13, 2020 · 4 comments · Fixed by #8837
Closed

Packer with HCL crashes on missing variable default. #8730

phaer opened this issue Feb 13, 2020 · 4 comments · Fixed by #8837
Labels
bug crash hcl2 stage/waiting-on-upstream This issue is waiting on an upstream change

Comments

@phaer
Copy link

phaer commented Feb 13, 2020

Overview of the Issue

I accidentally left out the default value for "proxmox_username" below, which results in packer crashing with a segmentation fault.

Reproduction Steps

Run the attached build file with the mentioned packer config

Packer version

Packer v1.5.3-dev
(23fa310)

Simplified Packer Buildfile

puppetmaster.pkr.hcl

variable "proxmox_url" {
  default = "https://192.168.122.58:8006/api2/json" // PROXMOX_URL
}
variable "proxmox_username" {
  type = string
}
variable "proxmox_password" {
  default = "not-the-"
}

build {
  sources = [
    "source.proxmox.puppetmaster",
  ]

  provisioner "shell" {
    inline = [
      "sleep 5"
    ]
  }

  post-processor "shell-local" {
    inline = [
      "sleep 5"
    ]
  }
}


source "proxmox" "puppetmaster" {
  proxmox_url = "${var.proxmox_url}"
  username = "${var.proxmox_username}"
  password = "${var.proxmox_password}"
}

Operating system and Environment details

OpenSuSE Leap 15.1, amd64

Log Fragments and crash.log files

crash.log
2020/02/13 19:38:52 [INFO] Packer version: 1.5.3-dev [go1.13.7 linux amd64]
2020/02/13 19:38:52 Checking 'PACKER_CONFIG' for a config file path
2020/02/13 19:38:52 'PACKER_CONFIG' not set; checking the default config file path
2020/02/13 19:38:52 Attempting to open config file: /home/phaer/.packerconfig
2020/02/13 19:38:52 [WARN] Config file doesn't exist: /home/phaer/.packerconfig
2020/02/13 19:38:52 Setting cache directory: /home/phaer/projects/diebin/cloud/packer/packer_cache
2020/02/13 19:38:52 Creating plugin client for path: /usr/local/bin/packer
2020/02/13 19:38:52 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-builder-proxmox"}
2020/02/13 19:38:52 Waiting for RPC address for: /usr/local/bin/packer
2020/02/13 19:38:52 packer-builder-proxmox plugin: [INFO] Packer version: 1.5.3-dev [go1.13.7 linux amd64]
2020/02/13 19:38:52 packer-builder-proxmox plugin: Checking 'PACKER_CONFIG' for a config file path
2020/02/13 19:38:52 packer-builder-proxmox plugin: 'PACKER_CONFIG' not set; checking the default config file path
2020/02/13 19:38:52 packer-builder-proxmox plugin: Attempting to open config file: /home/phaer/.packerconfig
2020/02/13 19:38:52 packer-builder-proxmox plugin: [WARN] Config file doesn't exist: /home/phaer/.packerconfig
2020/02/13 19:38:52 packer-builder-proxmox plugin: Setting cache directory: /home/phaer/projects/diebin/cloud/packer/packer_cache
2020/02/13 19:38:52 packer-builder-proxmox plugin: args: []string{"packer-builder-proxmox"}
2020/02/13 19:38:52 packer-builder-proxmox plugin: Plugin address: unix /tmp/packer-plugin709814317
2020/02/13 19:38:52 packer-builder-proxmox plugin: Waiting for connection...
2020/02/13 19:38:52 Received unix RPC address for /usr/local/bin/packer: addr is /tmp/packer-plugin709814317
2020/02/13 19:38:52 packer-builder-proxmox plugin: Serving a plugin connection...
2020/02/13 19:38:52 waiting for all plugin processes to complete...
2020/02/13 19:38:52 /usr/local/bin/packer: plugin process exited
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x7f39e6]

goroutine 1 [running]:
github.com/zclconf/go-cty/cty.Type.Equals(...)
	/go/pkg/mod/github.com/azr/go-cty@v1.1.1-0.20200203143058-28fcda2fe0cc/cty/type.go:39
github.com/zclconf/go-cty/cty/convert.Convert(0x0, 0x0, 0x0, 0x0, 0x494f040, 0xc000467738, 0x0, 0x0, 0x0, 0xc0006bdfe0, ...)
	/go/pkg/mod/github.com/azr/go-cty@v1.1.1-0.20200203143058-28fcda2fe0cc/cty/convert/public.go:43 +0x26
github.com/hashicorp/hcl/v2/hcldec.(*AttrSpec).decode(0xc00068e630, 0xc0004a4120, 0x0, 0x0, 0x0, 0xc0005ceac0, 0x0, 0x0, 0x0, 0x0, ...)
	/go/pkg/mod/github.com/hashicorp/hcl/v2@v2.3.0/hcldec/spec.go:207 +0x312
github.com/hashicorp/hcl/v2/hcldec.ObjectSpec.decode(0xc0005ba0f0, 0xc0004a4120, 0x0, 0x0, 0x0, 0xc0005ceac0, 0xc0006f0df0, 0x42f2d1, 0x434d570, 0xc0006f0df0, ...)
	/go/pkg/mod/github.com/hashicorp/hcl/v2@v2.3.0/hcldec/spec.go:79 +0x238
github.com/hashicorp/hcl/v2/hcldec.decode(0x494e280, 0xc0003d0a50, 0x0, 0x0, 0x0, 0xc0005ceac0, 0x494ef40, 0xc0005ba0f0, 0xde1d00, 0x492a000, ...)
	/go/pkg/mod/github.com/hashicorp/hcl/v2@v2.3.0/hcldec/decode.go:21 +0x118
github.com/hashicorp/hcl/v2/hcldec.Decode(...)
	/go/pkg/mod/github.com/hashicorp/hcl/v2@v2.3.0/hcldec/public.go:15
github.com/hashicorp/packer/hcl2template.decodeHCL2Spec(0x494e280, 0xc0003d0a50, 0xc0005ceac0, 0x7fa55c121300, 0xc00059c200, 0x0, 0x0, 0x0, 0xc000566000, 0x7fa561b08008, ...)
	/home/circleci/project/hcl2template/decode.go:17 +0xa0
github.com/hashicorp/packer/hcl2template.(*Parser).startBuilder(0xc000627370, 0xc00044e570, 0xc0005ceac0, 0xc0003f43c8, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/circleci/project/hcl2template/types.source.go:54 +0x2e4
github.com/hashicorp/packer/hcl2template.(*Parser).getBuilds(0xc0006f1370, 0xc0005ae300, 0x0, 0x0, 0xc0005ae300, 0x0, 0x0, 0x0)
	/home/circleci/project/hcl2template/types.packer_config.go:102 +0x1d5
github.com/hashicorp/packer/hcl2template.(*Parser).Parse(0xc000627370, 0x7ffcb01fefc5, 0x14, 0x0, 0xc0000dd138, 0xc0000dd1a8, 0x38, 0x40, 0xc0005ae080, 0xc000334fc0)
	/home/circleci/project/hcl2template/types.packer_config.go:150 +0xd1
github.com/hashicorp/packer/command.(*BuildCommand).GetBuildsFromHCL(0xc000334f30, 0x7ffcb01fefc5, 0x14, 0x0, 0x0, 0xc000566000, 0x1)
	/home/circleci/project/command/build.go:107 +0x123
github.com/hashicorp/packer/command.(*BuildCommand).GetBuilds(0xc000334f30, 0x7ffcb01fefc5, 0x14, 0x1, 0x1, 0x7fffffffffffffff, 0x0)
	/home/circleci/project/command/build.go:136 +0x543
github.com/hashicorp/packer/command.(*BuildCommand).RunContext(0xc000334f30, 0x494dc00, 0xc0000c7c80, 0xc00004e1a0, 0x1, 0x1, 0xc0000c7c80)
	/home/circleci/project/command/build.go:185 +0xca
github.com/hashicorp/packer/command.(*BuildCommand).Run(0xc000334f30, 0xc00004e1a0, 0x1, 0x1, 0x0)
	/home/circleci/project/command/build.go:55 +0x201
github.com/mitchellh/cli.(*CLI).Run(0xc0002f6640, 0xc0002f6640, 0x1, 0x1)
	/go/pkg/mod/github.com/mitchellh/cli@v1.0.0/cli.go:255 +0x1da
main.wrappedMain(0x0)
	/home/circleci/project/main.go:238 +0x853
main.realMain(0x0)
	/home/circleci/project/main.go:124 +0xbb
main.main()
	/home/circleci/project/main.go:34 +0x22
@phaer phaer added the bug label Feb 13, 2020
@azr azr added the hcl2 label Feb 14, 2020
@azr
Copy link
Contributor

azr commented Feb 14, 2020

Hey @phaer awesome, thanks for bubbling this up ! 🙏 Fixing this now

@azr azr added the crash label Feb 14, 2020
azr added a commit that referenced this issue Feb 14, 2020
@azr azr added the stage/waiting-on-upstream This issue is waiting on an upstream change label Feb 14, 2020
@azr
Copy link
Contributor

azr commented Feb 14, 2020

Hello there I think I have a fix with one of our upstream libraries zclconf/go-cty#44 and hopefully this is the correct fix and we'll get a patch real soon.

@azr
Copy link
Contributor

azr commented Mar 4, 2020

Hello there ! Turns out my fix was the wrong one and I just opened #8837 to fix this. Please tell me if this fixes the bug for you; binaries can be found here

@ghost
Copy link

ghost commented Apr 10, 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 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug crash hcl2 stage/waiting-on-upstream This issue is waiting on an upstream change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants