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

cmd/compile (or runtime): deferred calls are missed under certain situations #48898

Open
go101 opened this issue Oct 10, 2021 · 2 comments
Open

cmd/compile (or runtime): deferred calls are missed under certain situations #48898

go101 opened this issue Oct 10, 2021 · 2 comments

Comments

@go101
Copy link

@go101 go101 commented Oct 10, 2021

What version of Go are you using (go version)?

$ go version
go version go1.17.2 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

package main

func main() {
	defer func() {
		println(recover().(int))
	}()
	func() {
		func() (_ [2]int) { type _ int; return }()
		func() {
			defer func() {
				defer func() {
					recover()
				}()
				defer panic(3)
				panic(2)
			}()
			defer func() {
				recover()
			}()
			panic(1)
		}()
		defer func() {}()
	}()
	
	var x = 123
	func() {
		defer print(x) // not executed!
		func() {
			defer func() {}()
			panic(4)
		}()
	}()
}

Based on this one from here.

What did you expect to see?

Prints 1234.

What did you see instead?

Prints 4.

This issue is created by @ianlancetaylor's suggestion.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Oct 11, 2021

Works up to Go 1.13, fails with Go 1.14 to tip.

CC @danscales

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 14, 2021

Change https://golang.org/cl/356011 mentions this issue: cmd/compile: fix some defer bugs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants