Skip to content

Goexit with panic #147

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

Closed
bynil opened this issue Apr 5, 2020 · 1 comment
Closed

Goexit with panic #147

bynil opened this issue Apr 5, 2020 · 1 comment

Comments

@bynil
Copy link

bynil commented Apr 5, 2020

In article https://go101.org/article/panic-and-recover-more.html

package main

import "runtime"

func f() {
	defer func() {
		recover()
	}()
	defer panic("will cancel Goexit but should not")
	runtime.Goexit()
}

func main() {
	c := make(chan struct{})
	go func() {
		defer close(c)
		f()
		for {
			runtime.Gosched()
		}
	}()
	<-c
}

The following is another example neither gc nor gccgo compiles it correctly. The example program should exit quickly in running, but in fact it never exit if it is compiled with the current versions of gc and gccgo.

This example will exit since go1.14 runtime.Goexit can no longer be aborted by a recursive panic/recover. https://golang.org/doc/go1.14#pkg-runtime

@zigo101
Copy link
Collaborator

zigo101 commented Apr 5, 2020

Aha, you are right. I though the issue golang/go#29226 is still not closed so it might be not fixed yet.

Thanks for the correction!

@zigo101 zigo101 closed this as completed in f00a3a4 Apr 5, 2020
TapirLiu added a commit to golang101/golang101 that referenced this issue Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants