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

panic on recover (panic: reflect: call of reflect.Value.IsNil on struct Value) #1022

Closed
ldez opened this issue Jan 29, 2021 · 0 comments · Fixed by #1028
Closed

panic on recover (panic: reflect: call of reflect.Value.IsNil on struct Value) #1022

ldez opened this issue Jan 29, 2021 · 0 comments · Fixed by #1028
Assignees
Labels
area/core bug Something isn't working

Comments

@ldez
Copy link
Contributor

ldez commented Jan 29, 2021

The following program sample.go triggers a panic:

package main

import (
	"log"
)

func main() {
	defer func() {
		r := recover()
		if r != nil { // <- panic here
			log.Print(r)
		}
	}()

	panic("Ho Ho Ho!")
}

Expected result:

$ go run ./sample.go
2021/01/29 15:17:18 Ho Ho Ho!

Got:

$ yaegi ./sample.go
sample.go:10:6: panic
run: reflect: call of reflect.Value.IsNil on struct Value
goroutine 1 [running]:
runtime/debug.Stack(0x1, 0xc0002e4600, 0x40)
        /home/ldez/.gvm/gos/go1.15.7/src/runtime/debug/stack.go:24 +0x9f
github.com/traefik/yaegi/interp.(*Interpreter).eval.func1(0xc0000a5c70)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/interp/interp.go:485 +0xc5
panic(0xe06c40, 0xc00000f200)
        /home/ldez/.gvm/gos/go1.15.7/src/runtime/panic.go:969 +0x1b9
github.com/traefik/yaegi/interp.runCfg.func1(0xc000362370, 0xc0000a7600, 0xc0000a51f0)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/interp/run.go:184 +0x247
panic(0xe06c40, 0xc00000f200)
        /home/ldez/.gvm/gos/go1.15.7/src/runtime/panic.go:969 +0x1b9
reflect.Value.IsNil(...)
        /home/ldez/.gvm/gos/go1.15.7/src/reflect/value.go:1086
github.com/traefik/yaegi/interp.isNotNil.func1(0xc000362370, 0xc00043cde0)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/interp/run.go:3415 +0x26c
github.com/traefik/yaegi/interp.runCfg(0xc0000a7600, 0xc000362370)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/interp/run.go:190 +0x87
github.com/traefik/yaegi/interp.genFunctionWrapper.func2.1(0x1583100, 0x0, 0x0, 0x1583100, 0x7ffb1097a108, 0xc00006b800)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/interp/run.go:891 +0x3f4
reflect.callReflect(0xc00043cfc0, 0xc0000a54f0, 0xc0000a54d8)
        /home/ldez/.gvm/gos/go1.15.7/src/reflect/value.go:565 +0x32a
reflect.makeFuncStub(0x0, 0x0, 0x0, 0x0, 0xc0000a5728, 0x4d2067, 0xc00043cf00, 0xc00043cfc0, 0x1583100, 0x0, ...)
        /home/ldez/.gvm/gos/go1.15.7/src/reflect/asm_amd64.s:20 +0x42
reflect.Value.call(0xdca0c0, 0xc00043cfc0, 0x13, 0xefeec5, 0x4, 0xc00000f0a0, 0x0, 0x0, 0x0, 0x203000, ...)
        /home/ldez/.gvm/gos/go1.15.7/src/reflect/value.go:476 +0x8c7
reflect.Value.Call(0xdca0c0, 0xc00043cfc0, 0x13, 0xc00000f0a0, 0x0, 0x0, 0xc00043cfc0, 0x30, 0x28)
        /home/ldez/.gvm/gos/go1.15.7/src/reflect/value.go:337 +0xb9
github.com/traefik/yaegi/interp.runCfg.func1(0xc000362210, 0xc0000a6e00, 0xc0000a5a60)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/interp/run.go:175 +0x10b
panic(0xefc4a0, 0xc00000f100)
        /home/ldez/.gvm/gos/go1.15.7/src/runtime/panic.go:969 +0x1b9
github.com/traefik/yaegi/interp._panic.func1(0xc000362210, 0xc00007c9d0)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/interp/run.go:783 +0x7f
github.com/traefik/yaegi/interp.runCfg(0xc0000a6e00, 0xc000362210)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/interp/run.go:190 +0x87
github.com/traefik/yaegi/interp.(*Interpreter).run(0xc000360000, 0xc0000a6600, 0xc000362000)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/interp/run.go:121 +0x2b0
github.com/traefik/yaegi/interp.(*Interpreter).eval(0xc000360000, 0xc0002c8bd0, 0x90, 0x7ffd32fe0df4, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/interp/interp.go:577 +0x809
github.com/traefik/yaegi/interp.(*Interpreter).EvalPath(0xc000360000, 0x7ffd32fe0df4, 0x9, 0xc0002c8b00, 0x90, 0x0, 0x0, 0xc0000a8dd0)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/interp/interp.go:399 +0xfa
main.runFile(0xc000360000, 0x7ffd32fe0df4, 0x9, 0xc00007e300, 0x1)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/cmd/yaegi/run.go:123 +0xae
main.run(0xc000128030, 0x1, 0x1, 0x13, 0x13)
        /home/ldez/sources/go/src/github.com/traefik/yaegi/cmd/yaegi/run.go:89 +0x7e5
main.main()
        /home/ldez/sources/go/src/github.com/traefik/yaegi/cmd/yaegi/yaegi.go:144 +0x415
@mvertes mvertes added area/core bug Something isn't working labels Feb 1, 2021
@mvertes mvertes self-assigned this Feb 1, 2021
mvertes added a commit that referenced this issue Feb 1, 2021
A wrong logic was leading to panic in recover. Simplify the
workflow for clarity.

Fixes #1022.
traefiker pushed a commit that referenced this issue Feb 2, 2021
A wrong logic was leading to panic in recover. Simplify the
workflow for clarity.

Fixes #1022.
traefiker pushed a commit that referenced this issue Feb 2, 2021
A wrong logic was leading to panic in recover. Simplify the
workflow for clarity.

Fixes #1022.
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.

2 participants