Skip to content

Incorrect pointer type passed to yaml decoder in config.New() #20

@madana-i

Description

@madana-i

What

The following error occurred when using this library.

goroutine 1 [runnable]:
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0xc0000ff020?, 0xc000100930?, {0x58fda0?, 0xc000082950?, 0x198?})
        /go/pkg/mod/gopkg.in/[email protected]/decode.go:350 +0x285 fp=0xc000063580 sp=0xc000063578 pc=0x4d0505
gopkg.in/yaml%2ev2.(*decoder).mappingStruct(0xc0000ff020, 0xc0001008c0, {0x5b8300?, 0xc0000e3180?, 0x0?})
        /go/pkg/mod/gopkg.in/[email protected]/decode.go:750 +0x565 fp=0xc0000637a8 sp=0xc000063580 pc=0x4d3d05
gopkg.in/yaml%2ev2.(*decoder).mapping(0xc000063901?, 0xc0001008c0?, {0x5b8300?, 0xc0000e3180?, 0xc000084458?})
        /go/pkg/mod/gopkg.in/[email protected]/decode.go:626 +0x470 fp=0xc0000638f8 sp=0xc0000637a8 pc=0x4d2990
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0xc0000ff020, 0xc0001008c0, {0x58a200?, 0xc000084450?, 0x4cec8b?})
        /go/pkg/mod/gopkg.in/[email protected]/decode.go:372 +0x1a5 fp=0xc000063968 sp=0xc0000638f8 pc=0x4d0425
gopkg.in/yaml%2ev2.(*decoder).document(...)
        /go/pkg/mod/gopkg.in/[email protected]/decode.go:384
gopkg.in/yaml%2ev2.(*decoder).unmarshal(0x58dc00?, 0xc000084450?, {0x58a200?, 0xc000084450?, 0xffff981251c0?})
        /go/pkg/mod/gopkg.in/[email protected]/decode.go:360 +0x110 fp=0xc0000639d8 sp=0xc000063968 pc=0x4d0390
gopkg.in/yaml%2ev2.(*Decoder).Decode(0xc000063aa8, {0x58dc00, 0xc000084450})
        /go/pkg/mod/gopkg.in/[email protected]/yaml.go:130 +0x1b1 fp=0xc000063a60 sp=0xc0000639d8 pc=0x4ebdf1
github.com/AthenZ/athenz-client-sidecar/v2/config.New({0xffff8ffffd87?, 0xc000084028?})
        /go/pkg/mod/github.com/!athen!z/athenz-client-sidecar/[email protected]/config/config.go:298 +0x20b fp=0xc000063ac8 sp=0xc000063a60 pc=0x4eda0b
main.main()
        /go/src/k8s-athenz-sia/tools/yaml-to-env/main.go:26 +0x117 fp=0xc000063f40 sp=0xc000063ac8 pc=0x57a9d7
runtime.main()
        /opt/go/src/runtime/proc.go:267 +0x2bb fp=0xc000063fe0 sp=0xc000063f40 pc=0x43781b
runtime.goexit()
        /opt/go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc000063fe8 sp=0xc000063fe0 pc=0x4658a1

First, I suspected that the format of the yaml file was wrong and checked it, but the same file was working properly in some environments, so I checked the library implementation and found that the problem seemed to be caused by passing a double pointer in the following place. (Actually, after correcting the implementation, it now works correctly in my local environment.)

https://github.com/AthenZ/athenz-client-sidecar/blob/master/config/config.go#L298

Suggestion

err = yaml.NewDecoder(f).Decode(cfg)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions