Skip to content

runtime panics are not recoverable. #3510

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

Open
dgryski opened this issue Mar 3, 2023 · 2 comments
Open

runtime panics are not recoverable. #3510

dgryski opened this issue Mar 3, 2023 · 2 comments
Labels
bug Something isn't working core

Comments

@dgryski
Copy link
Member

dgryski commented Mar 3, 2023

~/go/src/github.com/dgryski/bug/rp $ cat main.go
package main

//go:noinline
func read(a []byte) byte {
	return a[2]
}

func main() {
	defer func() {
		if r := recover(); r != nil {
			println("caught a panic")
		}
	}()

	a := []byte{1}

	read(a)
}
~/go/src/github.com/dgryski/bug/rp $ go run main.go
caught a panic
~/go/src/github.com/dgryski/bug/rp $ tinygo run main.go
panic: runtime error: index out of range
error: failed to run compiled binary /var/folders/5b/_hr1d1fd3qn4t9vtfx5p61wm0000gp/T/tinygo4189450643/main: signal: abort trap

This is because runtimePanic() doesn't call _panic() but leads directly to abort().

https://github.com/tinygo-org/tinygo/blob/release/src/runtime/panic.go#L56

@dgryski
Copy link
Member Author

dgryski commented Mar 3, 2023

Fix here: #3511

@dgryski
Copy link
Member Author

dgryski commented Mar 3, 2023

Discovered while trying to get https://github.com/rasky/go-lzo/blob/master/decompress.go#L155 to work.

@deadprogram deadprogram added bug Something isn't working core labels Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core
Projects
None yet
Development

No branches or pull requests

2 participants