ghodss/yaml

Panic when trying to unmarshal specific yaml

ccampbell opened this issue · 9 comments

This is a pretty bizarre one. When trying to unmarshal this yaml:

Port: 7746
Processes:
    Something:
        Command: some command

I get this panic:

panic: reflect: reflect.Value.Set using unaddressable value

goroutine 1 [running]:
panic(0x3cdb80, 0xc820132680)
    /usr/local/Cellar/go/1.6.2/libexec/src/runtime/panic.go:481 +0x3e6
reflect.flag.mustBeAssignable(0x16)
    /usr/local/Cellar/go/1.6.2/libexec/src/reflect/value.go:229 +0x221
reflect.Value.Set(0x3a98e0, 0x0, 0x16, 0x3a98e0, 0xc82016e2c0, 0x16)
    /usr/local/Cellar/go/1.6.2/libexec/src/reflect/value.go:1328 +0x25
dj/vendor/github.com/ghodss/yaml.indirect(0x3a98e0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /Users/craig/go-clean/src/dj/vendor/github.com/ghodss/yaml/fields.go:48 +0x528
dj/vendor/github.com/ghodss/yaml.convertToJSONableObject(0x3ca880, 0xc820136630, 0xc8201346a0, 0x0, 0x0, 0x0, 0x0)
    /Users/craig/go-clean/src/dj/vendor/github.com/ghodss/yaml/yaml.go:106 +0xc9
dj/vendor/github.com/ghodss/yaml.convertToJSONableObject(0x3ca880, 0xc8201365d0, 0xc8200d7170, 0x0, 0x0, 0x0, 0x0)
    /Users/craig/go-clean/src/dj/vendor/github.com/ghodss/yaml/yaml.go:205 +0xf3a
dj/vendor/github.com/ghodss/yaml.convertToJSONableObject(0x3ca880, 0xc8201365a0, 0xc8200d7628, 0x0, 0x0, 0x0, 0x0)
    /Users/craig/go-clean/src/dj/vendor/github.com/ghodss/yaml/yaml.go:195 +0xb15
dj/vendor/github.com/ghodss/yaml.yamlToJSON(0xc820162000, 0x43, 0x243, 0xc8200d78a0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/craig/go-clean/src/dj/vendor/github.com/ghodss/yaml/yaml.go:89 +0x110
dj/vendor/github.com/ghodss/yaml.Unmarshal(0xc820162000, 0x43, 0x243, 0x3a9880, 0x78c480, 0x0, 0x0)
    /Users/craig/go-clean/src/dj/vendor/github.com/ghodss/yaml/yaml.go:32 +0xa8

Interestingly it seems like it might be something specific to the word Processes cause if I change that to Process or really any other word it works fine. I was previously using an older version of your library c3eb24a and it works fine there.

I'm having the same issue.

Here's a very basic sample that reproduces this issue: https://play.golang.org/p/-HW2JX08zd

nvm, looks like #7 is the fix.

@bacongobbler Did you verify this is fixed in latest?

@ghodss I am pretty sure @bacongobbler realized the issue he was experiencing was fixed with #7 (not that it was the same issue as the original ticket I made here)

@ccampbell Are you able to test your issue against latest?

Yep! I can verify that this was fixed in latest. Thank you!

@ccampbell not sure if it is relevant to your issue, but the example I put up does cause the same panic to trigger as shown in the OP, so either they are the same issue or at least related to each other. Either way, upgrading to master resolved the panic for me. :)

Aha! I just tried on latest master and it is working for me as well. Thanks!