-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
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