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
Assignees
Milestone

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Dec 20, 2020

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 this to the Go1.16 milestone Dec 20, 2020
@mdempsky mdempsky self-assigned this Dec 20, 2020
@mdempsky
Copy link
Member Author

@mdempsky mdempsky commented Dec 20, 2020

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

Loading

@mdempsky
Copy link
Member Author

@mdempsky mdempsky commented Dec 20, 2020

We weren't checking OAS2RECV either. :(

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 20, 2020

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

Loading

@mdempsky
Copy link
Member Author

@mdempsky mdempsky commented Dec 20, 2020

@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.)

Loading

@kivikakk
Copy link

@kivikakk kivikakk commented Dec 20, 2020

Fetching and compiling now, will report back shortly 👍

Loading

@kivikakk
Copy link

@kivikakk 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

Loading

@mdempsky
Copy link
Member Author

@mdempsky mdempsky commented Dec 20, 2020

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

Loading

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
3 participants