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: debugging, wrong line number attached to block #22365

Closed
dr2chase opened this issue Oct 20, 2017 · 1 comment
Closed

cmd/compile: debugging, wrong line number attached to block #22365

dr2chase opened this issue Oct 20, 2017 · 1 comment

Comments

@dr2chase
Copy link
Contributor

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

go1.10 devel

Does this issue reproduce with the latest release?

This does not appear in 1.9, but I think this is a new/revealed bug in the line numbering improved by https://go-review.googlesource.com/c/go/+/50610 for #21098.
It appeared after making the very-correct-looking change motivated by this comment
https://go-review.googlesource.com/c/go/+/50610/21/src/cmd/compile/internal/gc/ssa.go#228

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

amd64, linux or darwin

The bug can be seen by comparing the source for a cmd/compile/internal/ssa/testdata/hist with its debug log cmd/compile/internal/ssa/testdata/hist.dbg-gdb.nexts (the exact line numbers may change if/when another debugging CL lands).

Source code:

func main() {
	hist := make([]int, 10)
	var reader io.Reader = strings.NewReader(cannedInput) //gdb-dbg=(hist/A,cannedInput/A)
	if len(os.Args) > 1 {
		var err error
		reader, err = os.Open(os.Args[1])
		if err != nil {
			fmt.Fprintf(os.Stderr, "There was an error opening %s: %v\n", os.Args[1], err)
			return
		}
	}
	scanner := bufio.NewScanner(reader)

Debugging log:

  src/cmd/compile/internal/ssa/testdata/hist.go
35:	func main() {
36:		hist := make([]int, 10)
37:		var reader io.Reader = strings.NewReader(cannedInput) //gdb-dbg=(hist/A,cannedInput/A)
$1 =  []int = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
$2 = "1\n1\n1\n1\n2\n2\n2\n4\n4\n8\n"
38:		if len(os.Args) > 1 {
43:				return
47:		for scanner.Scan() {

Notice the return at line 43. This should not appear, the length of os.Args is zero, and the return is clearly not executed.

Not clear on the cause yet, not sure I'll personally get to this before the 1.10 freeze.
I would attack it by going over ssa.html to figure out where the line number goes wrong
(line numbers now appear there to assist with this sort of debugging)

cd cmd/compile/internal/ssa/testdata
GOSSAFUNC=main go build -gcflags '-N -l'  hist.go
@gopherbot
Copy link

Change https://golang.org/cl/74252 mentions this issue: cmd/compile: adjust Pos setting for "empty" blocks

@golang golang locked and limited conversation to collaborators Nov 8, 2018
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

2 participants