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 while looping over the HTTP recorder headers #775

Closed
kevinpollet opened this issue Jul 13, 2020 · 0 comments · Fixed by #777
Closed

Panic while looping over the HTTP recorder headers #775

kevinpollet opened this issue Jul 13, 2020 · 0 comments · Fixed by #777
Assignees
Labels
area/core bug Something isn't working
Milestone

Comments

@kevinpollet
Copy link
Member

The following program sample.go triggers a panic:

package main

import (
	"fmt"
	"net/http/httptest"
)

func main() {
	recorder := httptest.NewRecorder()
	recorder.Header().Add("Foo", "Bar")

	for key, value := range recorder.Header() {
		fmt.Println(key, value)
	}
}

Expected result:

$ go run ./sample.go
Foo [Bar]

Got:

$ yaegi ./sample.go
./simple.go:9:14: panic
reflect.Value.Call: call of nil function
goroutine 1 [running]:
runtime/debug.Stack(0x1, 0xc000148a00, 0x40)
	/Users/kevinpollet/.gvm/gos/go1.14.3/src/runtime/debug/stack.go:24 +0x9d
github.com/containous/yaegi/interp.(*Interpreter).Eval.func1(0xc000217dd8)
	/Users/kevinpollet/Documents/Dev/yaegi/interp/interp.go:333 +0xbc
panic(0x191eae0, 0x1c35b20)
	/Users/kevinpollet/.gvm/gos/go1.14.3/src/runtime/panic.go:969 +0x166
github.com/containous/yaegi/interp.runCfg.func1(0xc0001375e0, 0xc00013b400)
	/Users/kevinpollet/Documents/Dev/yaegi/interp/run.go:119 +0x20c
panic(0x191eae0, 0x1c35b20)
	/Users/kevinpollet/.gvm/gos/go1.14.3/src/runtime/panic.go:969 +0x166
reflect.Value.call(0xc000100900, 0xc0000107d0, 0x193, 0x1a4e27d, 0x4, 0x2262a78, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/kevinpollet/.gvm/gos/go1.14.3/src/reflect/value.go:357 +0x13d8
reflect.Value.Call(0xc000100900, 0xc0000107d0, 0x193, 0x2262a78, 0x0, 0x0, 0x1a4b840, 0x1, 0x2262a78)
	/Users/kevinpollet/.gvm/gos/go1.14.3/src/reflect/value.go:321 +0xb4
github.com/containous/yaegi/interp.callBin.func1(0xc000100900, 0xc0000107d0, 0x193, 0x2262a78, 0x0, 0x0, 0x0, 0x0, 0x0)
	/Users/kevinpollet/Documents/Dev/yaegi/interp/run.go:1077 +0x64
github.com/containous/yaegi/interp.callBin.func10(0xc0001375e0, 0xc00010b680)
	/Users/kevinpollet/Documents/Dev/yaegi/interp/run.go:1218 +0x1c2
github.com/containous/yaegi/interp.runCfg(0xc00013b400, 0xc0001375e0)
	/Users/kevinpollet/Documents/Dev/yaegi/interp/run.go:125 +0x6d
github.com/containous/yaegi/interp.(*Interpreter).run(0xc0001a61a0, 0xc00013ab00, 0xc000137540)
	/Users/kevinpollet/Documents/Dev/yaegi/interp/run.go:103 +0x247
github.com/containous/yaegi/interp.(*Interpreter).Eval(0xc0001a61a0, 0xc00016e1c0, 0xda, 0x0, 0x0, 0x0, 0x0, 0x0)
	/Users/kevinpollet/Documents/Dev/yaegi/interp/interp.go:416 +0x5f7
main.main()
	/Users/kevinpollet/Documents/Dev/yaegi/cmd/yaegi/yaegi.go:166 +0x6e2
mvertes added a commit that referenced this issue Jul 13, 2020
The range init AST execution was skipped, and range could work
only over variables or direct function calls. By setting the
start node to the start of init and not init itself, we ensure
that the init AST is always taken into account.

Fixes #775.
@mvertes mvertes self-assigned this Jul 13, 2020
@mvertes mvertes added area/core bug Something isn't working labels Jul 13, 2020
@mvertes mvertes added this to the v0.8.x milestone Jul 13, 2020
traefiker pushed a commit that referenced this issue Jul 13, 2020
The range init AST execution was skipped, and range could work
only over variables or direct function calls. By setting the
start node to the start of init and not init itself, we ensure
that the init AST is always taken into account.

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