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

recover not working correctly with runtime panics in Gnolang #2146

Closed
omarsy opened this issue May 18, 2024 · 1 comment
Closed

recover not working correctly with runtime panics in Gnolang #2146

omarsy opened this issue May 18, 2024 · 1 comment
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related

Comments

@omarsy
Copy link
Member

omarsy commented May 18, 2024

Description:

The recover function does not seem to handle runtime panics correctly in Gnolang, whereas the following code works fine in Golang.

Steps to Reproduce:

  1. Create and run the following code in Go. The program completes without panic due to the recover.
package main

func p() {
	defer func() {
		recover()
	}()
	i := 0
	i = 1 / i
}

func main() {
	p()
}
package main

type s struct {
	el func()
}

func p() {
	var el *s
	defer func() {
		recover()
	}()
	el.el()
}

func main() {
	p()
}
  1. Transpose the same code to Gnolang and run it.
package main

func p() {
	defer func() {
		recover()
	}()
	i := 0
	i = 1 / i
}

func main() {
	p()
}
package main

type s struct {
	el func()
}

func p() {
	var el *s
	defer func() {
		recover()
	}()
	el.el()
}

func main() {
	p()
}

Expected Behavior:

The program should terminate normally without panicking because the recover in the deferred function should catch the panic caused by division by zero or use of nil pointer...

Actual Behavior:

In Gnolang, the program does not seem to handle the runtime panic, causing the program to crash.

@thehowl
Copy link
Member

thehowl commented Jul 24, 2024

Duplicate #1148

@thehowl thehowl closed this as not planned Won't fix, can't repro, duplicate, stale Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Development

Successfully merging a pull request may close this issue.

4 participants