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/link: bad debug_info on macOS 10.12.1 when using cgo (but only under very specific circumstances) #17897

Closed
aarzilli opened this issue Nov 12, 2016 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@aarzilli
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

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

go version go1.7.3 darwin/amd64

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/vagrant/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rm/ywx69srx1kq_dtjz2ynznn000000gp/T/go-build432262881=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"

What did you do?

I can't figure out a simpler way to reproduce this:

$ go get github.com/derekparker/delve
$ cd $GOPATH/src/github.com/derekparker/delve/_fixtures
$ go build -gcflags='-N -l' ./cgotest.go
$ cd $GOPATH/src/github.com/derekparker/delve/proc
$ go build -gcflags='-N -l' ../_fixtures/cgotest.go
$ gobjdump --dwarf $GOPATH/src/github.com/derekparker/delve/_fixtures/cgotest | grep -B1 -A5 -e 'goid$'
$ gobjdump --dwarf $GOPATH/src/github.com/derekparker/delve/proc/cgotest | grep -B1 -A5 -e 'goid$'

(gobjdump is GNU objdump)

What did you expect to see?

The same output from both gobjdump | grep.

What did you see instead?

When I compile cgotest.go while I'm in the same directory cgotest.go is I get:

 <2><20313>: Abbrev Number: 11 (DW_TAG_member)
    <20314>   DW_AT_name        : (indirect string, offset: 0xc358): goid
    <20318>   DW_AT_data_member_location: 3 byte block: 23 c0 1 	(DW_OP_plus_uconst: 192)
    <2031c>   DW_AT_type        : <0x1f3e0>
 <2><20324>: Abbrev Number: 11 (DW_TAG_member)
    <20325>   DW_AT_name        : (indirect string, offset: 0xc35d): waitsince
    <20329>   DW_AT_data_member_location: 3 byte block: 23 c8 1 	(DW_OP_plus_uconst: 200)

When I compile cgotest.go by specifying ../_fixtures/cgotest.go I get:

 <2><20173>: Abbrev Number: 21 (DW_TAG_member)
    <20174>   DW_AT_name        : (indirect string, offset: 0xc353): goid
    <20178>   DW_AT_data_member_location: 3 byte block: 23 c0 1 	(DW_OP_plus_uconst: 192)
 <2><2017c>: Abbrev Number: 21 (DW_TAG_member)
    <2017d>   DW_AT_name        : (indirect string, offset: 0xc358): waitsince
    <20181>   DW_AT_data_member_location: 3 byte block: 23 c8 1 	(DW_OP_plus_uconst: 200)
 <2><20185>: Abbrev Number: 12 (DW_TAG_member)

Note how the DW_AT_type attribute of goid is gone. The output of -x is identical in both cases.

@quentinmit quentinmit added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 15, 2016
@quentinmit quentinmit added this to the Go1.8Maybe milestone Nov 15, 2016
@quentinmit
Copy link
Contributor

/cc @ianlancetaylor @randall77

@ianlancetaylor
Copy link
Contributor

I can't recreate this on amd64 GNU/Linux using either Go 1.7 or tip.

@ianlancetaylor
Copy link
Contributor

@aarzilli The DWARF generation is very different on tip than in 1.7, as it has moved from cmd/link to cmd/compile. Would it be possible for you to reset this using tip?

@aarzilli
Copy link
Contributor Author

I can't recreate this on amd64 GNU/Linux using either Go 1.7 or tip.

Yes, the macOS 10.12.1 part of the bug description is a necessary precondition.

I can't reproduce this on tip, looks like some of the changes to dwarf must have fixed it (or prevented it from triggering in this circumstance).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants