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 assignment to math.NaN() #1453

Closed
bbp-brieuc opened this issue Sep 7, 2022 · 0 comments · Fixed by #1468
Closed

panic on assignment to math.NaN() #1453

bbp-brieuc opened this issue Sep 7, 2022 · 0 comments · Fixed by #1468
Labels
area/core bug Something isn't working

Comments

@bbp-brieuc
Copy link

bbp-brieuc commented Sep 7, 2022

The following program sample.go triggers a panic

package main

import (
	"fmt"

	"github.com/traefik/yaegi/interp"
	"github.com/traefik/yaegi/stdlib"
)


func main() {
	interpreter := interp.New(interp.Options{})
	interpreter.Use(stdlib.Symbols)
	fmt.Println(interpreter.Eval("import \"math\""))
	// the line below triggers a panic
	// it should fail since the code to interpret is invalid, but not panic
	fmt.Println(interpreter.Eval("math.NaN() <- 4"))
}

Expected result

0xc0000b8420 <nil>
<invalid reflect.Value> runtime error: invalid memory address or nil pointer dereference

Got

a panic about a nil pointer dereference

Yaegi Version

v0.14.2

Additional Notes

No response

@mvertes mvertes added bug Something isn't working area/core labels Sep 7, 2022
mvertes added a commit to mvertes/yaegi that referenced this issue Oct 3, 2022
Not performing this check was leading to a panic at runtime.
It now fail early with a compile error.

Fixes traefik#1453.
traefiker pushed a commit to mvertes/yaegi that referenced this issue Oct 4, 2022
Not performing this check was leading to a panic at runtime.
It now fail early with a compile error.

Fixes traefik#1453.
traefiker pushed a commit that referenced this issue Oct 4, 2022
Not performing this check was leading to a panic at run-time. It now fails early with a compile error.

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