Skip to content

(reflect?) issue with github.com/bradfitz/gomemcache/memcache #1499

Open
@mpl

Description

@mpl

The following program sample.go triggers an unexpected result

package main

import (
	"log"

	"github.com/bradfitz/gomemcache/memcache"
)

func main() {
	mc := memcache.New("localhost:11211", "localhost:11212")
	mc.Set(&memcache.Item{Key: "foo", Value: []byte("my value")})

	it, err := mc.Get("foo")
	if err != nil {
		log.Fatal(err)
	}
	println(it.Key)
	for _, v := range it.Value {
		println(string(v))
	}

}

Expected result

$ docker run -p 11211:11211 --name my-memcache2 -d memcached -p 11211
178dd9c73df173a19616bcf3d65538f462fe71d83d03f5c3cc40cd17376f0fbe
$ docker run -p 11212:11212 --name my-memcache -d memcached -p 11212
1dd4a193c0ec32c0ef31b04601988ee8ca3d2529806380a69dc025b840a58686
$
$ GO111MODULE=off go run ./main.go 
foo
m
y
 
v
a
l
u
e

Got

% yaegi run ./main.go 
/Users/mpl/src/github.com/bradfitz/gomemcache/memcache/memcache.go:542:9: panic
./main.go:10:8: panic
run: reflect: Call using func(*bufio.ReadWriter, *struct { Key string; Value []uint8; Flags uint32; Expiration int32; Xcasid uint64 }) error as type func(*struct { Timeout time.Duration; MaxIdleConns int; Xselector interp.valueInterface; Xlk sync.Mutex; Xfreeconn map[string][]*struct { Xnc net.Conn; Xrw *bufio.ReadWriter; Xaddr net.Addr; Xc *unsafe2.dummy } }, *bufio.ReadWriter, *struct { Key string; Value []uint8; Flags uint32; Expiration int32; Xcasid uint64 }) error
goroutine 1 [running]:
runtime/debug.Stack()
	/Users/mpl/go1/src/runtime/debug/stack.go:24 +0x65
github.com/traefik/yaegi/interp.(*Interpreter).Execute.func1()
	/Users/mpl/src/github.com/traefik/yaegi/interp/program.go:146 +0x94
panic({0x1978e40, 0xc0004a6270})
	/Users/mpl/go1/src/runtime/panic.go:884 +0x212
github.com/traefik/yaegi/interp.runCfg.func1()
	/Users/mpl/src/github.com/traefik/yaegi/interp/run.go:192 +0x148
panic({0x1978e40, 0xc0004a6270})
	/Users/mpl/go1/src/runtime/panic.go:884 +0x212
github.com/traefik/yaegi/interp.runCfg.func1()
	/Users/mpl/src/github.com/traefik/yaegi/interp/run.go:192 +0x148
panic({0x1978e40, 0xc0004a6270})
	/Users/mpl/go1/src/runtime/panic.go:884 +0x212
reflect.Value.call({0xc000624de0?, 0xc0003c64b0?, 0xc00004a980?}, {0x1a9e70e, 0x4}, {0xc0003c64e0, 0x2, 0xc0000a0a20?})
	/Users/mpl/go1/src/reflect/value.go:440 +0x1abf
reflect.Value.Call({0xc000624de0?, 0xc0003c64b0?, 0x16?}, {0xc0003c64e0?, 0x1a6ef60?, 0xc0002cfad0?})
	/Users/mpl/go1/src/reflect/value.go:368 +0xbc
github.com/traefik/yaegi/interp.call.func9.2({0xc0003c64e0?, 0xc0003c64b0?, 0x2?})
	/Users/mpl/src/github.com/traefik/yaegi/interp/run.go:1288 +0x3c
github.com/traefik/yaegi/interp.call.func9(0xc0002cfad0)
	/Users/mpl/src/github.com/traefik/yaegi/interp/run.go:1303 +0x122f
github.com/traefik/yaegi/interp.runCfg(0xc0000a0000, 0xc0002cfad0, 0x1?, 0xc000469ac0?)
	/Users/mpl/src/github.com/traefik/yaegi/interp/run.go:200 +0x29d
github.com/traefik/yaegi/interp.genFunctionWrapper.func1.1({0xc000012960, 0x1, 0x1?})
	/Users/mpl/src/github.com/traefik/yaegi/interp/run.go:1002 +0x4a5
reflect.Value.call({0xc0007ec480?, 0xc0003c6330?, 0x1011c9f?}, {0x1a9e70e, 0x4}, {0xc000012948, 0x1, 0x10d4fde?})
	/Users/mpl/go1/src/reflect/value.go:584 +0x8c5
reflect.Value.Call({0xc0007ec480?, 0xc0003c6330?, 0x1055ff2?}, {0xc000012948?, 0x1a9c4c0?, 0x218d801?})
	/Users/mpl/go1/src/reflect/value.go:368 +0xbc
github.com/traefik/yaegi/interp.call.func9.2({0xc000012948?, 0xc0003c6330?, 0xc000012588?})
	/Users/mpl/src/github.com/traefik/yaegi/interp/run.go:1288 +0x3c
github.com/traefik/yaegi/interp.call.func9(0xc0002cf4a0)
	/Users/mpl/src/github.com/traefik/yaegi/interp/run.go:1303 +0x122f
github.com/traefik/yaegi/interp.runCfg(0xc0002d7c20, 0xc0002cf4a0, 0xc0002d70e0?, 0x0?)
	/Users/mpl/src/github.com/traefik/yaegi/interp/run.go:200 +0x29d
github.com/traefik/yaegi/interp.(*Interpreter).run(0xc0002cc000, 0xc0002d70e0, 0xc0002ce000?)
	/Users/mpl/src/github.com/traefik/yaegi/interp/run.go:119 +0x38e
github.com/traefik/yaegi/interp.(*Interpreter).Execute(0xc0002cc000, 0xc0007f4d50)
	/Users/mpl/src/github.com/traefik/yaegi/interp/program.go:172 +0x24b
github.com/traefik/yaegi/interp.(*Interpreter).eval(0xc0002cc000, {0xc000400300?, 0x16e?}, {0x7ff7bfeff5da?, 0xc000400000?}, 0x6e?)
	/Users/mpl/src/github.com/traefik/yaegi/interp/interp.go:561 +0x5c
github.com/traefik/yaegi/interp.(*Interpreter).EvalPath(0xc0002cc000, {0x7ff7bfeff5da, 0x9})
	/Users/mpl/src/github.com/traefik/yaegi/interp/interp.go:510 +0xab
main.runFile(0x7ff7bfeff5da?, {0x7ff7bfeff5da, 0x9}, 0x0)
	/Users/mpl/src/github.com/traefik/yaegi/cmd/yaegi/run.go:153 +0xee
main.run({0xc0001241a0?, 0x1, 0x1})
	/Users/mpl/src/github.com/traefik/yaegi/cmd/yaegi/run.go:116 +0xbec
main.main()
	/Users/mpl/src/github.com/traefik/yaegi/cmd/yaegi/yaegi.go:133 +0xcf

Yaegi Version

eee72d1

Additional Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions