microsoft / azure-vhd-utils

Azure VHD utilities.
Other
96 stars 41 forks source link

`vhd inspect footer --path /path/to/disk.vhd` panics! #11

Closed colemickens closed 8 years ago

colemickens commented 8 years ago
$ go get github.com/Microsoft/azure-vhd-utils-for-go

$ azure-vhd-utils-for-go inspect footer /nix/store/igjb0w7jpjk43sxwk53l21mz118ivghn-azure-image/disk.vhd

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x18 pc=0x47ebbb]

goroutine 1 [running]:
text/template.(*Template).ExecuteTemplate(0x0, 0x7f4c059961e8, 0xc82003c010, 0x8859d0, 0xa, 0x7fae20, 0xc8200205a0, 0x0, 0x0)
    /nix/store/zfjn6abbd49iyiai3fnvdnxjkqjqwxxi-go-1.5.3/share/go/src/text/template/exec.go:117 +0x3b
main.showVhdFooter(0xc8200c8640)
    /home/cole/code/gopkgs/src/github.com/Microsoft/azure-vhd-utils-for-go/vhdInspectCmdHandler.go:164 +0x6d0
github.com/codegangsta/cli.Command.Run(0x879370, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8815b0, 0xf, 0x0, ...)
    /home/cole/code/gopkgs/src/github.com/codegangsta/cli/command.go:174 +0x1397
github.com/codegangsta/cli.(*App).RunAsSubcommand(0xc8200c83c0, 0xc8200c8280, 0x0, 0x0)
    /home/cole/code/gopkgs/src/github.com/codegangsta/cli/app.go:298 +0x11d4
github.com/codegangsta/cli.Command.startApp(0x879898, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8ccf60, 0x1d, 0x0, ...)
    /home/cole/code/gopkgs/src/github.com/codegangsta/cli/command.go:249 +0x74f
github.com/codegangsta/cli.Command.Run(0x879898, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8ccf60, 0x1d, 0x0, ...)
    /home/cole/code/gopkgs/src/github.com/codegangsta/cli/command.go:65 +0x79
github.com/codegangsta/cli.(*App).Run(0xc8200c8140, 0xc82000a0a0, 0x5, 0x5, 0x0, 0x0)
    /home/cole/code/gopkgs/src/github.com/codegangsta/cli/app.go:187 +0x1135
main.main()
    /home/cole/code/gopkgs/src/github.com/Microsoft/azure-vhd-utils-for-go/vhd.go:27 +0x2e0

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /nix/store/zfjn6abbd49iyiai3fnvdnxjkqjqwxxi-go-1.5.3/share/go/src/runtime/asm_amd64.s:1721 +0x1
anuchandy commented 8 years ago

@colemickens just confirming are you using the latest bits, there was bug in locating template path which i fixed. I just pulled the latest code and tried. It worked

If you have an older version then you might want to remove 'azure-vhd-utils-for-go' from GOPATH/src/Microsoft before "go getting" the latest.

colemickens commented 8 years ago

I just destroyed my entire GOPATH and reran it. Still repros.

$ cd $GOPATH/src/github.com/Mirosoft/azure-vhd-utils-for-go

$ git log
[...]
commit f291a0767221c47a9413038b58a4bbfb3b62ab95
[...]
Date:   Sun Mar 6 21:22:04 2016 -0800
[...]
anuchandy commented 8 years ago

@colemickens could you try this:

1] cd $GOPATH/src/github.com/Mirosoft/azure-vhd-utils-for-go 2] go build 3] ./azure-vhd-utils-for-go inspect footer /nix/store/igjb0w7jpjk43sxwk53l21mz118ivghn-azure-image/disk.vhd

colemickens commented 8 years ago

Yup, that works.

anuchandy commented 8 years ago

cool! The issue is, when we do "go get azure-vhd-utils-for-go", it build the binary "azure-vhd-utils-for-go" and put it in "$GOPATH/bin". This binary is unable to locate the template path because it's relative in the source code.

colemickens commented 8 years ago

Yup, I have a similar problem with one of my projects. I'm currently solving it by distributing the binary + template folder in a docker container and encouraging people to run it that way, but that feels heavy for a tool like this. The other thing I'd considered was just embedding the template files as string constants in my Go source code, but I'm not crazy about that idea either.

colemickens commented 8 years ago

Thanks for the fast support!

anuchandy commented 8 years ago

Thanks for sharing your experience, I guess in case of this tool - reasonable solution is to include template file content as string constants, I will do that.

Let me know if you come across better way of handling this.

anuchandy commented 8 years ago

closing, this issue is addressed by moving the templates to source file.