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

panic: runtime error: invalid memory address or nil pointer dereference #3

Closed
sam-cogan opened this issue Jul 17, 2017 · 14 comments
Closed
Labels

Comments

@sam-cogan
Copy link
Contributor

sam-cogan commented Jul 17, 2017

I'm trying to do a very basic DSC configuration of a VM provisioned in Azure using the Azure Builder. The VM gets built fine, but falls over when running the DSC provisioner. I turned on detailed errors but it doesn't mean a lot to me.

Provisioners:

"provisioners": [ { "type": "powershell", "inline": [ "winrm quickconfig -q" ] }, { "type": "dsc", "manifest_file": "basic.ps1", "configuration_name": "HelloWorld", "configuration_params": { "-filename": "testing" } } ]

Error:
`2017/07/17 20:47:56 packer.exe:
2017/07/17 20:47:56 Uploading file to '/tmp/packer-dsc-pull/manifest/basic.ps1'

2017/07/17 20:47:58 packer.exe: #< CLIXML

2017/07/17 20:47:59 packer-provisioner-dsc.exe: panic: runtime error: invalid memory address or nil pointer dereference

2017/07/17 20:47:59 packer-provisioner-dsc.exe: [signal 0xc0000005 code=0x0 addr=0x0 pc=0x4621ba]

2017/07/17 20:47:59 packer-provisioner-dsc.exe:

2017/07/17 20:47:59 packer-provisioner-dsc.exe: goroutine 39 [running]:

2017/07/17 20:47:59 packer-provisioner-dsc.exe: github.com/mefellows/packer-dsc/provisioner/dsc.(*Provisioner).createDscScript(0xc08201d800, 0xae56f0, 0x14, 0xc0821a6b20, 0x13, 0x0, 0x0, 0xc0821028a0, 0xa, 0x0, ...)

2017/07/17 20:47:59 packer-provisioner-dsc.exe: /gopath/src/github.com/mefellows/packer-dsc/provisioner/dsc/provisioner.go:323 +0x12a

2017/07/17 20:47:59 packer-provisioner-dsc.exe: github.com/mefellows/packer-dsc/provisioner/dsc.(*Provisioner).Provision(0xc08201d800, 0x14d6340, 0xc0820e8cc0, 0x14d6388, 0xc082097160, 0x0, 0x0)

2017/07/17 20:47:59 packer-provisioner-dsc.exe: /gopath/src/github.com/mefellows/packer-dsc/provisioner/dsc/provisioner.go:281 +0x1fb0

2017/07/17 20:47:59 packer-provisioner-dsc.exe: github.com/mitchellh/packer/packer/rpc.(*ProvisionerServer).Provision(0xc0820e8720, 0x1, 0xc082168300, 0x0, 0x0)

2017/07/17 20:47:59 packer-provisioner-dsc.exe: /gopath/src/github.com/mitchellh/packer/packer/rpc/provisioner.go:64 +0x2c0

2017/07/17 20:47:59 packer-provisioner-dsc.exe: reflect.Value.call(0x95d940, 0x9cf320, 0x13, 0xa85f98, 0x4, 0xc08202ded8, 0x3, 0x3, 0x0, 0x0, ...)

2017/07/17 20:47:59 packer-provisioner-dsc.exe: /goroot/src/reflect/value.go:432 +0x1211

2017/07/17 20:47:59 packer-provisioner-dsc.exe: reflect.Value.Call(0x95d940, 0x9cf320, 0x13, 0xc08202ded8, 0x3, 0x3, 0x0, 0x0, 0x0)

2017/07/17 20:47:59 packer-provisioner-dsc.exe: /goroot/src/reflect/value.go:300 +0xb8

2017/07/17 20:47:59 packer-provisioner-dsc.exe: net/rpc.(*service).call(0xc0820ea280, 0xc0820ea240, 0xc082096d90, 0xc08205a700, 0xc0821061a0, 0x8d8740, 0xc0821682f0, 0xca, 0x89bec0, 0xc082168300, ...)

2017/07/17 20:47:59 packer-provisioner-dsc.exe: /goroot/src/net/rpc/server.go:383 +0x1c8
2017/07/17 20:47:59 packer-provisioner-dsc.exe: created by net/rpc.(*Server).ServeCodec

2017/07/17 20:47:59 packer-provisioner-dsc.exe: /goroot/src/net/rpc/server.go:477 +0x4b3`

@mefellows mefellows added the bug label Jul 18, 2017
@mefellows
Copy link
Owner

Well, a nil pointer dereference is never a good thing! I can't claim that I know this works on Azure as I've never tested on it. I believe it should work as the provisioner is (at least in theory) cloud agnostic.

I'll take a peek at the code and see what we can find.

@sam-cogan
Copy link
Contributor Author

Thanks, as you say it should be pretty agnostic to being in Azure so it should work. I'm quite open the the fact it may be me doing something wrong, but I can't really make much of the error.

@mefellows
Copy link
Owner

The code is just over a year old now (so it might be somewhat incompatible with current mainline packer), so what I'm going to do is update all of the dependencies, vendor the code and fix the NPD - this should at the very least return back the error to the UI so that we can investigate further.

@mefellows
Copy link
Owner

Could you please check out the latest release (v.0.0.3)? At the very least, we should see what the cause of that NPD is (it is the step that uploads the DSC bootstrap script that is failing).

@sam-cogan
Copy link
Contributor Author

Ok, still erroring, but getting a much better error message this time, namely:

Error creating DSC runner: open \tmp\packer-dsc-runner135556803: The system cannot find the path specified.

The file it mentions is definitely missing, but it's not clear where it should come from.

Here's the log around the error:

2017/07/19 17:31:55 ui: azure-arm: Uploading manifest...
2017/07/19 17:31:56 packer.exe: 2017/07/19 17:31:56 [INFO] starting remote command: powershell.exe -Command "New-Item -ItemType directory -Force -ErrorAction SilentlyContinue -Path /tmp/packer-dsc-pull/manifest"
2017/07/19 17:31:56 packer.exe: 2017/07/19 17:31:56 [INFO] command 'powershell.exe -Command "New-Item -ItemType directory -Force -ErrorAction SilentlyContinue -Path /tmp/packer-dsc-pull/manifest"' exited with code: 0
2017/07/19 17:31:56 packer.exe: 2017/07/19 17:31:56 [INFO] RPC endpoint: Communicator ended with: 0
2017/07/19 17:31:56 [INFO] 414 bytes written for 'stdout'
2017/07/19 17:31:56 [INFO] 0 bytes written for 'stderr'
2017/07/19 17:31:56 [INFO] RPC client: Communicator ended with: 0
2017/07/19 17:31:56 [INFO] RPC endpoint: Communicator ended with: 0
2017/07/19 17:31:56 ui: azure-arm:
2 17:31:56 [INFO] 332 bytes written for 'uploadData'
2017/07/19 17:31:56 packer.exe: 2017/07/19 17:31:56 Uploading file to '/tmp/packer-dsc-pull/manifest/test.ps1'
2017/07/19 17:31:58 packer.exe: #< CLIXML
2017/07/19 17:31:59 [INFO] (telemetry) ending dsc
2017/07/19 17:31:59 [INFO] (telemetry) found error: Error creating DSC runner: open \tmp\packer-dsc-runner135556803: The system cannot find the path specified.
2017/07/19 17:31:59 ui: ==> azure-arm: Step "StepProvision" failed017/07/19 17:31:56 packer-provisioner-dsc.exe: 2017/07/19 17:31:56 [INFO] 414 bytes written for 'stdout'

@sam-cogan
Copy link
Contributor Author

Ok after some digging through the code I found the issue. The provider expects to find a /tmp folder in the root of the drive where your packer file is on (on your local machine, not the provisioned node) it is using this to create the dsc runner. If the folder doesn't exist then this error occurs. Interestingly the error you get in the log is on the next step when it can't find that file, not when it can't create it.

Might be worth using either the folder with the the packer file in, or even windows\temp to store this rather than expecting to find tmp, which most people won't have.

@mefellows
Copy link
Owner

Nice pickup! I think using the environment variable instead of /tmp makes sense, will leave this open for enhancement.

Presumably as a workaround you can pop in a provisioner step to create the dir for now?

@sam-cogan
Copy link
Contributor Author

Oh yeah, I can workaround it for now, not a big deal.

@mefellows
Copy link
Owner

Awesome, thanks again - will try to get this fixed over the weekend.

@sam-cogan
Copy link
Contributor Author

Did you ever get a chance to look at this? I am now trying to use this on hosted build agents where I don't have the ability to create a tmp folder.

@mefellows
Copy link
Owner

sorry @sam-cogan, obviously I hadn't looked at it - thanks for the PR.

We'll get it out soon, and hopefully it sorts your issue.

@sam-cogan
Copy link
Contributor Author

No problem, turned out to be easier than I thought to fix so I went ahead.

@Marcus-James-Adams
Copy link

I was just wondering if the fix for this ever got put into the released code?

@sam-cogan
Copy link
Contributor Author

sam-cogan commented Aug 24, 2019

Yes, this got rolled in from the PR I added in Jan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants