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: init info of OAS node in a select case is being dropped #48289

Closed
danscales opened this issue Sep 9, 2021 · 3 comments
Closed

Comments

@danscales
Copy link
Contributor

Issues exists in current master (go1.18-devel), but has probably existed for a while.

When an OAS node is converted to an OSELRECV2 node in tcSelect(), any DCL node in the Init field (due to a := assignment) is being dropped, since a completely new node is being created and the Init field was not set.

Thanks for the test case created by @mdempsky:

package main

func main() {
	ch := make(chan int, 1)

	var ptrs [2]*int
	for i := range ptrs {
		ch <- i
		select {
		case x := <-ch:
			ptrs[i] = &x
		}
	}

	for i, ptr := range ptrs {
		if *ptr != i {
			println("FAIL:", *ptr, "!=", i)
		}
	}
}
@danscales danscales self-assigned this Sep 9, 2021
@gopherbot
Copy link

Change https://golang.org/cl/348569 mentions this issue: cmd/compile: fix case where init info of OAS node is dropped

@rhysh
Copy link
Contributor

rhysh commented Nov 10, 2021

The problem this fixes was introduced by 0328c3b. It affects the Go 1.17 series, including go1.17.3.

$ ./bin/go version && ./bin/go run ~/issue48289.go
go version go1.16.10 linux/amd64

$ ./bin/go version && ./bin/go run ~/issue48289.go
go version go1.17.3 linux/amd64
FAIL: 1 != 0

$ ./bin/go version && ./bin/go run ~/issue48289.go
go version devel +88e1415d08 Thu Dec 17 04:43:59 2020 +0000 linux/amd64

$ ./bin/go version && ./bin/go run ~/issue48289.go
go version devel +0328c3b660 Thu Dec 17 15:50:38 2020 +0000 linux/amd64
FAIL: 1 != 0

@gopherbot please consider this for backport to 1.17

@gopherbot
Copy link

Backport issue(s) opened: #49510 (for 1.16), #49511 (for 1.17).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants