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: no file/line info for init function #8777

Closed
dvyukov opened this issue Sep 19, 2014 · 5 comments
Closed

cmd/compile: no file/line info for init function #8777

dvyukov opened this issue Sep 19, 2014 · 5 comments

Comments

@dvyukov
Copy link
Member

dvyukov commented Sep 19, 2014

go version devel +6aa1064ad564 Wed Sep 17 20:38:50 2014 -0700 darwin/amd64

Build and run the following 3-file program:

// main/main.go
package main
import _ "a"
func main() {
}

// a/1.go
package a
func foo(i interface{}, c1 complex64, c2 complex128) int {
    if i == nil {
        panic("nil")
    }
    return 0
}
func bar(b bool, s string, c byte, i int) (interface{}, complex64, complex128) {
    if b {
        panic("nil")
    }
    return nil, 0, 0
}

// a/2.go
package a
var X = foo(bar(false, "foo", byte(0), 1))


The output is:

panic: nil

goroutine 1 [running]:
runtime.gopanic(0x32aa0, 0x208088080)
    src/runtime/panic.go:354 +0xdb fp=0x2080b7ef0 sp=0x2080b7e88
a.foo(0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    a/1.go:4 +0x6c fp=0x2080b7f28 sp=0x2080b7ef0
a.init()
    ?:0 +0xc4 fp=0x2080b7f90 sp=0x2080b7f28
main.init()
    main/main.go:4 +0x42 fp=0x2080b7f98 sp=0x2080b7f90
runtime.main()
    src/runtime/proc.go:58 +0xe4 fp=0x2080b7fe0 sp=0x2080b7f98
runtime.goexit()
    src/runtime/proc.c:1669 fp=0x2080b7fe8 sp=0x2080b7fe0


Note that a.init function does not have file/line info -- "?:0".
a.init should be associated with "a/2.go:2".
@rsc
Copy link
Contributor

rsc commented Sep 19, 2014

Comment 1:

Labels changed: added release-go1.5.

Status changed to Accepted.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@rsc rsc removed accepted labels Apr 14, 2015
@rsc
Copy link
Contributor

rsc commented May 19, 2015

@dr2chase possibility

@rsc rsc changed the title cmd/gc: no file/line info for init function cmd/compile: no file/line info for init function Jun 8, 2015
@rsc
Copy link
Contributor

rsc commented Jun 29, 2015

Too late for Go 1.5.

@rsc rsc modified the milestones: Go1.6Early, Go1.5 Jun 29, 2015
@rsc rsc modified the milestones: Unplanned, Go1.6Early Nov 4, 2015
@odeke-em
Copy link
Member

I don't think this is an issue anymore btw

$ go version
go version devel +be91515 Thu Jul 28 03:03:42 2016 +0000 darwin/amd64
$ go run main.go 
panic: nil

goroutine 1 [running]:
panic(0x562c0, 0xc42000a0e0)
    /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/runtime/panic.go:500 +0x1a1
_/Users/emmanuelodeke/Desktop/openSrc/bugs/golang/8777/a.foo(0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/emmanuelodeke/Desktop/openSrc/bugs/golang/8777/a/1.go:4 +0x8a
_/Users/emmanuelodeke/Desktop/openSrc/bugs/golang/8777/a.init()
    /Users/emmanuelodeke/Desktop/openSrc/bugs/golang/8777/a/2.go:2 +0xb8
main.init()
    /Users/emmanuelodeke/Desktop/openSrc/bugs/golang/8777/main.go:5 +0x2e
exit status 2

init has the line information /Users/emmanuelodeke/Desktop/openSrc/bugs/golang/8777/a/2.go:2 +0xb8

Given your setup @dvyukov

$ ls -lrth
total 8
drwxr-xr-x  4 emmanuelodeke  staff   136B 28 Jul 03:04 a
-rw-r--r--  1 emmanuelodeke  staff    55B 28 Jul 03:05 main.go
 find . -type f -exec cat {} \;
// a/1.go
package a
func foo(i interface{}, c1 complex64, c2 complex128) int {
    if i == nil {
        panic("nil")
    }
    return 0
}
func bar(b bool, s string, c byte, i int) (interface{}, complex64, complex128) {
    if b {
        panic("nil")
    }
    return nil, 0, 0
}
// a/2.go
package a
var X = foo(bar(false, "foo", byte(0), 1))
// main.go
package main
import _ "./a"
func main() {
}

@bradfitz
Copy link
Contributor

Will close then, thanks!

@golang golang locked and limited conversation to collaborators Jul 28, 2017
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

5 participants