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: runtime panic due to bad devirtualization #43292

Closed
mdempsky opened this issue Dec 20, 2020 · 7 comments
Closed

cmd/compile: runtime panic due to bad devirtualization #43292

mdempsky opened this issue Dec 20, 2020 · 7 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@mdempsky
Copy link
Member

This program should run without crashing, but currently panics at tip:

package main

type I interface { M() chan int }

type A int
func (A) M() chan int { return nil }

type B int
func (B) M() chan int { return nil }

func main() {
	c := I(A(0))

	b := make(chan I, 1)
	b <- B(0)

	for i := 0; i < 2; i++ {
		select {
		case c = <-b:
		case <-c.M():
		default:
		}
	}
}

Based on test case reported by @kivikakk in #42284.

@mdempsky mdempsky added NeedsFix The path to resolution is known, but the work has not been done. release-blocker labels Dec 20, 2020
@mdempsky mdempsky added this to the Go1.16 milestone Dec 20, 2020
@mdempsky mdempsky self-assigned this Dec 20, 2020
@mdempsky
Copy link
Member Author

The issue is reassigned doesn't check for OSELRECV/OSELRECV2.

@mdempsky
Copy link
Member Author

We weren't checking OAS2RECV either. :(

@gopherbot
Copy link

Change https://golang.org/cl/279352 mentions this issue: cmd/compile: recognize reassignments involving receives

@mdempsky
Copy link
Member Author

@kivikakk I believe CL 279352 should fix your issue. Can you try testing that for me please?

In case you're not familiar with Gerrit, the procedure to fetch and checkout the change locally are:

git fetch https://go.googlesource.com/go refs/changes/52/279352/1
git checkout FETCH_HEAD

(Other options are available if you click the "DOWNLOAD" link at golang.org/cl/279352, but they all amount to fetching that commit ref and then using some git command.)

@kivikakk
Copy link

Fetching and compiling now, will report back shortly 👍

@kivikakk
Copy link

kivikakk commented Dec 20, 2020

Success! The use case I reported in #42284 (comment) no longer panics:

$ ~/Code/go/bin/go version
go version devel +00468b24ae Sun Dec 20 01:16:30 2020 -0800 darwin/arm64
$ ~/Code/go/bin/go run main.go
2020/12/20 20:41:45 online

@mdempsky
Copy link
Member Author

@kivikakk Great, thank you for confirming, and again for the report! I've submitted the fix. Cheers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants