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

gopkg.in/yaml.v3 issue #1519

Closed
caius-kong opened this issue Mar 1, 2023 · 2 comments · Fixed by #1525
Closed

gopkg.in/yaml.v3 issue #1519

caius-kong opened this issue Mar 1, 2023 · 2 comments · Fixed by #1525
Labels
area/core bug Something isn't working

Comments

@caius-kong
Copy link

The following program sample.go triggers an unexpected result

package main

import (
	"fmt"
	"os"

	"gopkg.in/yaml.v3"
)

func main() {
	readYAML("sdz.yaml")
}

func readYAML(path string) {
	b, err := os.ReadFile(path)
	if err != nil {
		fmt.Printf("read yaml failed: %v\n", err)
	}

	var doc = make(map[interface{}]interface{})
	if err := yaml.Unmarshal(b, &doc); err != nil {
		fmt.Printf("unmarshal yaml failed: %v\n", err)
	}
}

Expected result

map[components:map[schemas:map.......

Got

/Users/caius_kong/go/src/gopkg.in/yaml.v3/readerc.go:79:2: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/readerc.go:49:7: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/readerc.go:114:5: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/scannerc.go:689:5: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/scannerc.go:664:6: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/parserc.go:69:5: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/parserc.go:232:11: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/parserc.go:153:9: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/parserc.go:121:2: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/decode.go:81:5: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/decode.go:63:5: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/decode.go:148:2: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/yaml.go:290:10: panic
/Users/caius_kong/go/src/gopkg.in/yaml.v3/yaml.go:89:9: panic
./sample.go:17:12: panic
./sample.go:13:2: panic
run: reflect: Call using *struct { Xerror int; Xproblem string; Xproblem_offset int; Xproblem_value int; Xproblem_mark struct { Xindex int; Xline int; Xcolumn int }; Xcontext string; Xcontext_mark struct { Xindex int; Xline int; Xcolumn int }; Xread_handler func(*unsafe2.dummy, []uint8) (int, error); Xinput_reader io.Reader; Xinput []uint8; Xinput_pos int; Xeof bool; Xbuffer []uint8; Xbuffer_pos int; Xunread int; Xnewlines int; Xraw_buffer []uint8; Xraw_buffer_pos int; Xencoding int; Xoffset int; Xmark struct { Xindex int; Xline int; Xcolumn int }; Xhead_comment []uint8; Xline_comment []uint8; Xfoot_comment []uint8; Xtail_comment []uint8; Xstem_comment []uint8; Xcomments []struct { Xscan_mark struct { Xindex int; Xline int; Xcolumn int }; Xtoken_mark struct { Xindex int; Xline int; Xcolumn int }; Xstart_mark struct { Xindex int; Xline int; Xcolumn int }; Xend_mark struct { Xindex int; Xline int; Xcolumn int }; Xhead []uint8; Xline []uint8; Xfoot []uint8 }; Xcomments_head int; Xstream_start_produced bool; Xstream_end_produced bool; Xflow_level int; Xtokens []struct { Xtyp int; Xstart_mark struct { Xindex int; Xline int; Xcolumn int }; Xend_mark struct { Xindex int; Xline int; Xcolumn int }; Xencoding int; Xvalue []uint8; Xsuffix []uint8; Xprefix []uint8; Xstyle int8; Xmajor int8; Xminor int8 }; Xtokens_head int; Xtokens_parsed int; Xtoken_available bool; Xindent int; Xindents []int; Xsimple_key_allowed bool; Xsimple_keys []struct { Xpossible bool; Xrequired bool; Xtoken_number int; Xmark struct { Xindex int; Xline int; Xcolumn int } }; Xsimple_keys_by_tok map[int]int; Xstate int; Xstates []int; Xmarks []struct { Xindex int; Xline int; Xcolumn int }; Xtag_directives []struct { Xhandle []uint8; Xprefix []uint8 }; Xaliases []struct { Xanchor []uint8; Xindex int; Xmark struct { Xindex int; Xline int; Xcolumn int } }; Xdocument *struct { Xnodes []struct { Xtyp int; Xtag []uint8; Xscalar struct { Xvalue []uint8; Xlength int; Xstyle int8 }; Xsequence struct { Xitems_data []int; Xstyle int8 }; Xmapping struct { Xpairs_data []struct { Xkey int; Xvalue int }; Xpairs_start *struct { Xkey int; Xvalue int }; Xpairs_end *struct { Xkey int; Xvalue int }; Xpairs_top *struct { Xkey int; Xvalue int }; Xstyle int8 }; Xstart_mark struct { Xindex int; Xline int; Xcolumn int }; Xend_mark struct { Xindex int; Xline int; Xcolumn int } }; Xversion_directive *struct { Xmajor int8; Xminor int8 }; Xtag_directives_data []struct { Xhandle []uint8; Xprefix []uint8 }; Xtag_directives_start int; Xtag_directives_end int; Xstart_implicit int; Xend_implicit int; Xstart_mark struct { Xindex int; Xline int; Xcolumn int }; Xend_mark struct { Xindex int; Xline int; Xcolumn int } } } as type *unsafe2.dummy
goroutine 1 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x64
github.com/traefik/yaegi/interp.(*Interpreter).Execute.func1()
        github.com/traefik/yaegi/interp/program.go:146 +0x74
panic({0x1016e8200, 0x14000704270})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1016e8200, 0x14000704270})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1016e8200, 0x14000704270})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1016e8200, 0x14000704270})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1016e8200, 0x14000704270})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp._panic.func1(0x1400104eb00?)
        github.com/traefik/yaegi/interp/run.go:901 +0x50
github.com/traefik/yaegi/interp.runCfg(0x1400133ec80, 0x1400104eb00, 0x3300000000000000?, 0x1015a91a0?)
        github.com/traefik/yaegi/interp/run.go:213 +0x21c
github.com/traefik/yaegi/interp.genFunctionWrapper.func1.1({0x14000704258, 0x1, 0x1?})
        github.com/traefik/yaegi/interp/run.go:1015 +0x3d8
reflect.Value.call({0x14001712c60?, 0x140016ad050?, 0x100c07830?}, {0x101379725, 0x4}, {0x140016acfa8, 0x1, 0x0?})
        reflect/value.go:584 +0x688
reflect.Value.Call({0x14001712c60?, 0x140016ad050?, 0x140025567c8?}, {0x140016acfa8?, 0x140025567c8?, 0x100c255c8?})
        reflect/value.go:368 +0x90
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:190 +0x230
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
github.com/traefik/yaegi/interp.runCfg.func1()
        github.com/traefik/yaegi/interp/run.go:205 +0x11c
panic({0x1015c4b40, 0x1400058e6d0})
        runtime/panic.go:884 +0x204
reflect.Value.call({0x14000114240?, 0x14001c6b068?, 0x140002be538?}, {0x101379725, 0x4}, {0x140016ad6b0, 0x2, 0x140008a0e40?})
        reflect/value.go:440 +0x1478
reflect.Value.Call({0x14000114240?, 0x14001c6b068?, 0x30?}, {0x140016ad6b0?, 0x140002be501?, 0x1400104e8f0?})
        reflect/value.go:368 +0x90
github.com/traefik/yaegi/interp.callBin.func2({0x14000114240?, 0x14001c6b068?, 0x182?}, {0x140016ad6b0?, 0x140002be628?, 0x100e61e5c?})
        github.com/traefik/yaegi/interp/run.go:1506 +0x28
github.com/traefik/yaegi/interp.callBin.func9(0x1400104e8f0?)
        github.com/traefik/yaegi/interp/run.go:1650 +0x140
github.com/traefik/yaegi/interp.runCfg(0x14000e91540, 0x1400104e8f0, 0x140015ea725?, 0x14001612380?)
        github.com/traefik/yaegi/interp/run.go:213 +0x21c
github.com/traefik/yaegi/interp.call.func9(0x1400104e840)
        github.com/traefik/yaegi/interp/run.go:1442 +0x798
github.com/traefik/yaegi/interp.runCfg(0x14000e82780, 0x1400104e840, 0x140002be9b8?, 0x14001612380?)
        github.com/traefik/yaegi/interp/run.go:213 +0x21c
github.com/traefik/yaegi/interp.call.func9(0x1400104e790)
        github.com/traefik/yaegi/interp/run.go:1442 +0x798
github.com/traefik/yaegi/interp.runCfg(0x14000ea12c0, 0x1400104e790, 0x101ef45b8?, 0x1015c3cc0?)
        github.com/traefik/yaegi/interp/run.go:213 +0x21c
github.com/traefik/yaegi/interp.call.func9(0x1400104e6e0)
        github.com/traefik/yaegi/interp/run.go:1442 +0x798
github.com/traefik/yaegi/interp.runCfg(0x14000854000, 0x1400104e6e0, 0x101c06a20?, 0x14001612380?)
        github.com/traefik/yaegi/interp/run.go:213 +0x21c
github.com/traefik/yaegi/interp.call.func9(0x1400104e630)
        github.com/traefik/yaegi/interp/run.go:1442 +0x798
github.com/traefik/yaegi/interp.runCfg(0x1400069b680, 0x1400104e630, 0x10137b3d7?, 0x14001612380?)
        github.com/traefik/yaegi/interp/run.go:213 +0x21c
github.com/traefik/yaegi/interp.call.func9(0x1400104e580)
        github.com/traefik/yaegi/interp/run.go:1442 +0x798
github.com/traefik/yaegi/interp.runCfg(0x14000cc6a00, 0x1400104e580, 0x0?, 0x14001612380?)
        github.com/traefik/yaegi/interp/run.go:213 +0x21c
github.com/traefik/yaegi/interp.call.func9(0x1400104e4d0)
        github.com/traefik/yaegi/interp/run.go:1442 +0x798
github.com/traefik/yaegi/interp.runCfg(0x14000cfc280, 0x1400104e4d0, 0x140002bf778?, 0x14001612a80?)
        github.com/traefik/yaegi/interp/run.go:213 +0x21c

Yaegi Version

0.15.0

Additional Notes

if traefik 2.6.3, this ok

@ldez ldez changed the title use gopkg.in/yaml.v3 issue gopkg.in/yaml.v3 issue Mar 1, 2023
@mvertes mvertes added bug Something isn't working area/core labels Mar 1, 2023
mvertes added a commit that referenced this issue Mar 14, 2023
The logic of patching reflect struct representation has been fixed
in presence of function fields and to better handle indirect
recursivity (struct recursive through nested struct).

Fixes #1519.
traefiker pushed a commit that referenced this issue Mar 21, 2023
The logic of patching reflect struct representation has been fixed in presence of function fields and to better handle indirect recursivity (struct recursive through nested struct).

Fixes #1519.
@caiuskong
Copy link

caiuskong commented Mar 23, 2023

@mvertes
Just merge to master, not published yet...
Hope to integrate into the latest traefik as soon as possible.

@caiuskong
Copy link

hi @mvertes ,
I have seen that yaegi v0.15.1 has already fixed the issue, but traefik (go.mod) currently only updates the yaegi version to v0.15.0. Can it be updated to v0.15.1 as soon as possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants