Skip to content

x/tools/go/ssa: multiple assign ssa.FieldAddr instr order error #55086

Closed
@visualfc

Description

@visualfc

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

$ go version
go version go1.18.4 darwin/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

go version -m $(which ssadump) Output
$ go version -m $(which ssadump)
/Users/vfc/go/bin/ssadump: go1.18.4
	path	golang.org/x/tools/cmd/ssadump
	mod	golang.org/x/tools	(devel)
	dep	golang.org/x/mod	v0.6.0-dev.0.20220419223038-86c51ed26bb4	h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
	dep	golang.org/x/sys	v0.0.0-20220722155257-8c9f86f7a55f	h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
	build	-compiler=gc
	build	CGO_ENABLED=1
	build	CGO_CFLAGS="-g -O2"
	build	CGO_CPPFLAGS=
	build	CGO_CXXFLAGS="-g -O2"
	build	CGO_LDFLAGS="-g -O2"
	build	GOARCH=amd64
	build	GOOS=darwin
	build	GOAMD64=v1
	build	vcs=git
	build	vcs.revision=9d7fa4a49fed984f3980240b804508eff5988360
	build	vcs.time=2022-09-05T11:27:21Z
	build	vcs.modified=false

What did you do?

main.go

package main

type P struct{ i int }

func main() {
	var m int
	var p *P
	defer func() {
		recover()
		println(m)
	}()
	m, p.i = 3, 2
}

$ ssadump -build=F main.go

func init(): ....
func main$1(): ...

# Name: command-line-arguments.main
# Package: command-line-arguments
# Location: /Users/vfc/code/vtest/main.go:5:6
# Recover: 1
func main():
0:                                                                entry P:0 S:0
	t0 = new int (m)                                                   *int
	t1 = make closure main$1 [t0]                                    func()
	defer t1()
	t2 = &nil:*P.i [#0]                                                *int
	*t0 = 3:int
	*t2 = 2:int
	rundefers
	return
1:                                                              recover P:0 S:0
	return

What did you expect to see?

the func main() instr order *t0 = 3:int before of t2 = &nil:*P.i [#0]
run line m, p.i = 3, 2 p.i is panic, but befor m is set, result is 3.

	*t0 = 3:int
	t2 = &nil:*P.i [#0]                                                *int
	*t2 = 2:int

What did you see instead?

the the func main() instr order error, the *ssa.FieldAddr &nil:*P.i [#0] before of *t0 = 3:int.
run line m, p.i = 3, 2 p.i is panic, m not set, result is 0.

	t2 = &nil:*P.i [#0]                                                *int
	*t0 = 3:int
	*t2 = 2:int

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions