-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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/go: incorrect DW_AT_comp_dir of package runtime/cgo in section .debug_info #48319
Comments
Change https://golang.org/cl/348991 mentions this issue: |
The C objects file in runtime/cgo: root@DESKTOP-S0J32Q2:/mnt/h/1.code/7.godev/go/pkg/linux_amd64/runtime# ar -x cgo.a root@DESKTOP-S0J32Q2:/mnt/h/1.code/7.godev/go/pkg/linux_amd64/runtime# objdump --dwarf=rawline _x006.o _x006.o: file format elf64-x86-64 Raw dump of debug contents of section .debug_line: Offset: 0x0 Length: 675 DWARF Version: 3 Prologue Length: 421 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -5 Line Range: 14 Opcode Base: 13 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 arg Opcode 3 has 1 arg Opcode 4 has 1 arg Opcode 5 has 1 arg Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 arg Opcode 10 has 0 args Opcode 11 has 0 args Opcode 12 has 1 arg The Directory Table (offset 0x1b): 1 /usr/include/x86_64-linux-gnu/bits 2 /usr/lib/gcc/x86_64-linux-gnu/9/include 3 /usr/include 4 /usr/include/x86_64-linux-gnu/bits/types The File Name Table (offset 0x9d): Entry Dir Time Size Name 1 0 0 0 gcc_linux_amd64.c 2 1 0 0 types.h 3 2 0 0 stddef.h 4 3 0 0 time.h 5 1 0 0 pthreadtypes.h 6 4 0 0 __sigset_t.h 7 4 0 0 sigset_t.h 8 3 0 0 signal.h 9 3 0 0 stdint.h 10 4 0 0 struct_FILE.h 11 4 0 0 FILE.h 12 3 0 0 stdio.h 13 1 0 0 sys_errlist.h 14 0 0 0 libcgo.h 15 3 0 0 stdlib.h 16 1 0 0 sigthread.h 17 3 0 0 pthread.h 18 0 0 0 libcgo_unix.h 19 3 0 0 string.h 20 3 0 0 errno.h ……………………………… objdump --dwarf=info _x006.o|grep DW_AT_comp_dir <15> DW_AT_comp_dir : (indirect string, offset: 0x1ce): /mnt/h/1.code/7.godev/go/src/runtime/cgo The go binary: objdump --dwarf=rawline hello hello: file format elf64-x86-64 Raw dump of debug contents of section .zdebug_line: Offset: 0x0 Length: 560 DWARF Version: 2 Prologue Length: 378 Minimum Instruction Length: 1 Initial value of 'is_stmt': 1 Line Base: -4 Line Range: 10 Opcode Base: 11 Opcodes: Opcode 1 has 0 args Opcode 2 has 1 arg Opcode 3 has 1 arg Opcode 4 has 1 arg Opcode 5 has 1 arg Opcode 6 has 0 args Opcode 7 has 0 args Opcode 8 has 0 args Opcode 9 has 1 arg Opcode 10 has 0 args The Directory Table (offset 0x19): 1 /mnt/h/1.code/7.godev/go/src/sync 2 /mnt/h/1.code/7.godev/go/src/sync/atomic 3 /mnt/h/1.code/7.godev/go/src/internal/race 4 /mnt/h/1.code/7.godev/go/src/runtime The File Name Table (offset 0xb5): Entry Dir Time Size Name 1 0 0 0 2 1 0 0 cond.go 3 1 0 0 mutex.go 4 1 0 0 runtime2.go 5 1 0 0 map.go 6 2 0 0 value.go 7 1 0 0 once.go 8 1 0 0 pool.go 9 1 0 0 poolqueue.go 10 1 0 0 rwmutex.go 11 1 0 0 waitgroup.go 12 1 0 0 runtime.go 13 2 0 0 doc.go 14 3 0 0 norace.go 15 4 0 0 debug.go 16 4 0 0 alg.go ……………… `objdump --dwarf=info hello|grep DW_AT_comp_dir <22> DW_AT_comp_dir : . <28f> DW_AT_comp_dir : . <2852> DW_AT_comp_dir : . <29d1> DW_AT_comp_dir : . <312c> DW_AT_comp_dir : . <31ef> DW_AT_comp_dir : . <32c6> DW_AT_comp_dir : . <34bb> DW_AT_comp_dir : . <36b7> DW_AT_comp_dir : . <38e2> DW_AT_comp_dir : . <10581> DW_AT_comp_dir : . <10875> DW_AT_comp_dir : . <10ac3> DW_AT_comp_dir : . <10b73> DW_AT_comp_dir : . <10c11> DW_AT_comp_dir : . <10ce2> DW_AT_comp_dir : . <1177d> DW_AT_comp_dir : . <1182d> DW_AT_comp_dir : . <11929> DW_AT_comp_dir : . <119e6> DW_AT_comp_dir : . <11acb> DW_AT_comp_dir : . <11c11> DW_AT_comp_dir : . objdump: Error: LEB value too large <4d247> DW_AT_comp_dir : . <4d96b> DW_AT_comp_dir : . <4da35> DW_AT_comp_dir : . <4db07> DW_AT_comp_dir : . <5f90e> DW_AT_comp_dir : (indirect string, offset: 0xe): /tmp/go-build <5f99c> DW_AT_comp_dir : (indirect string, offset: 0xe): /tmp/go-build <600de> DW_AT_comp_dir : (indirect string, offset: 0xe): /tmp/go-build <6016c> DW_AT_comp_dir : (indirect string, offset: 0xe): /tmp/go-build <601bb> DW_AT_comp_dir : (indirect string, offset: 0x39a): /mnt/h/1.code/7.godev/go/src/runtime/cgo <6067c> DW_AT_comp_dir : (indirect string, offset: 0x39a): /mnt/h/1.code/7.godev/go/src/runtime/cgo <60cd0> DW_AT_comp_dir : (indirect string, offset: 0x39a): /mnt/h/1.code/7.godev/go/src/runtime/cgo <619cf> DW_AT_comp_dir : (indirect string, offset: 0x39a): /mnt/h/1.code/7.godev/go/src/runtime/cgo <6234b> DW_AT_comp_dir : (indirect string, offset: 0x39a): /mnt/h/1.code/7.godev/go/src/runtime/cgo <62901> DW_AT_comp_dir : (indirect string, offset: 0x39a): /mnt/h/1.code/7.godev/go/src/runtime/cgo <62d8b> DW_AT_comp_dir : (indirect string, offset: 0x39a): /mnt/h/1.code/7.godev/go/src/runtime/cgo <63821> DW_AT_comp_dir : (indirect string, offset: 0x39a): /mnt/h/1.code/7.godev/go/src/runtime/cgo <63d77> DW_AT_comp_dir : (indirect string, offset: 0x39a): /mnt/h/1.code/7.godev/go/src/runtime/cgo <642ba> DW_AT_comp_dir : (indirect string, offset: 0x39a): /mnt/h/1.code/7.godev/go/src/runtime/cgo <64b70> DW_AT_comp_dir : (indirect string, offset: 0x39a): /mnt/h/1.code/7.godev/go/src/runtime/cgo` The dwarfinfo of go files is different from c files. The DW_AT_comp_dir of go files is always ".". But there is absolutely path in The Directory Table in debug_line, which is generated by linker. So it's can't be replace GOROOT to fix path with -fdebug-prefix-map. |
Change https://golang.org/cl/351851 mentions this issue: |
…kages include C files" This reverts commit abbfec2. Reason to revert: breaks darwin builders. Updates #48319 Change-Id: I50c957a6a3f46ffcdaf972bdbb0574867ddc9486 Reviewed-on: https://go-review.googlesource.com/c/go/+/351851 Trust: Cuong Manh Le <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Go Bot <[email protected]>
Change https://golang.org/cl/353352 mentions this issue: |
Reconsidering this in the context of #50183: the I think it is important for reproducibility that the value of |
Change https://golang.org/cl/380915 mentions this issue: |
Change https://golang.org/cl/380914 mentions this issue: |
…property The test previously checked that the DWARF DW_AT_comp_dir attribute matched GOROOT_FINAL. However, on further consideration, we believe that DW_AT_comp_dir should not actually match GOROOT_FINAL: the DWARF spec says that DW_AT_comp_dir records “the current working directory of the compilation command that produced this compilation unit”, but the actual working directory of the compilation command proper is a throwaway directory in the build cache — it is neither stable nor meaningful. However, the test was getting at a real issue that we do care about: namely, that the binary produced by a 'go build' command with cgo enabled should not reuse a dependency that embeds a stale GOROOT_FINAL. This change refactors the test to verify the latter property instead of checking DW_AT_comp_dir specifically. For #50183 Updates #48319 Change-Id: I0b1151d9ba3d0ff903f72e27850306406e5cb518 Reviewed-on: https://go-review.googlesource.com/c/go/+/380914 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
C archives for packages in GOROOT are shipped along with binary releases of the Go toolchain. Although we build the toolchain with GOROOT_FINAL set, we don't know actually know where the release will be installed: the user's real GOROOT can differ arbitrarily from our GOROOT_FINAL. (In the specific case of toolchains installed through golang.org/dl wrappers, the release's GOROOT_FINAL is /usr/local/go but the actual GOROOT to which the release is installed is $HOME/sdk/$(go env GOVERSION).) Fixes #50183 Updates #48319 Change-Id: If10a42f90c725300bbcb89c3b5b01a2d93ab6ef7 Reviewed-on: https://go-review.googlesource.com/c/go/+/380915 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
…property The test previously checked that the DWARF DW_AT_comp_dir attribute matched GOROOT_FINAL. However, on further consideration, we believe that DW_AT_comp_dir should not actually match GOROOT_FINAL: the DWARF spec says that DW_AT_comp_dir records “the current working directory of the compilation command that produced this compilation unit”, but the actual working directory of the compilation command proper is a throwaway directory in the build cache — it is neither stable nor meaningful. However, the test was getting at a real issue that we do care about: namely, that the binary produced by a 'go build' command with cgo enabled should not reuse a dependency that embeds a stale GOROOT_FINAL. This change refactors the test to verify the latter property instead of checking DW_AT_comp_dir specifically. For golang#50183 Updates golang#48319 Change-Id: I0b1151d9ba3d0ff903f72e27850306406e5cb518 Reviewed-on: https://go-review.googlesource.com/c/go/+/380914 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
C archives for packages in GOROOT are shipped along with binary releases of the Go toolchain. Although we build the toolchain with GOROOT_FINAL set, we don't know actually know where the release will be installed: the user's real GOROOT can differ arbitrarily from our GOROOT_FINAL. (In the specific case of toolchains installed through golang.org/dl wrappers, the release's GOROOT_FINAL is /usr/local/go but the actual GOROOT to which the release is installed is $HOME/sdk/$(go env GOVERSION).) Fixes golang#50183 Updates golang#48319 Change-Id: If10a42f90c725300bbcb89c3b5b01a2d93ab6ef7 Reviewed-on: https://go-review.googlesource.com/c/go/+/380915 Trust: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Russ Cox <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes.
What operating system and processor architecture are you using (
go env
)?Two go toolchains are installed on the same mechine, and they are almost the same expect for the
GOROOT
andGOTOOLDIR
.The details about the first go toolchain (henceforce called "toolchain1") are as follows:
~/goroot1/bin/go
OutputThe details about the second go toolchain (henceforce called "toolchain2") are as follows:
~/goroot2/bin/go
OutputWhat did you do?
hello.go:
The "hello.go" was built separately with the "toolchain1" and "toolchain2".
What did you expect to see?
When the "hello.go" was built with "toolchain1" , the DW_AT_comp_dir of runtime/cgo in binary was expected to be "……/goroot1/src/runtime/cgo".
When the "hello.go" was built with "toolchain2" , the DW_AT_comp_dir of runtime/cgo in binary was expected to be "……/goroot2/src/runtime/cgo".
What did you see instead?
When the "hello.go" was built with "toolchain1" and "toolchain2", the DW_AT_comp_dir of runtime/cgo is always "……/goroot1/src/runtime/cgo".
The text was updated successfully, but these errors were encountered: