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

dr2chase opened this issue Oct 20, 2017 · 1 comment

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

dr2chase opened this issue Oct 20, 2017 · 1 comment


Copy link

@dr2chase dr2chase commented Oct 20, 2017

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 for #21098.
It appeared after making the very-correct-looking change motivated by this comment

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)
	scanner := bufio.NewScanner(reader)

Debugging log:

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

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Oct 29, 2017

Change mentions this issue: cmd/compile: adjust Pos setting for "empty" blocks

@gopherbot gopherbot closed this in a042221 Nov 8, 2017
@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.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.