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

debug/buildinfo: module info not read when buildinfo section length exceeds 64KB #61644

Closed
c-kruse opened this issue Jul 28, 2023 · 6 comments
Closed
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@c-kruse
Copy link
Contributor

c-kruse commented Jul 28, 2023

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

$ go version
go version go1.20.6 linux/amd64

Does this issue reproduce with the latest release?

Y

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

linux amd64

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/christian/.cache/go-build"
GOENV="/home/christian/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/christian/go/pkg/mod"
GONOPROXY="github.com/sensu/*"
GONOSUMDB="github.com/sensu/*"
GOOS="linux"
GOPATH="/home/christian/go"
GOPRIVATE="github.com/sensu/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.6"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1935503120=/tmp/go-build -gno-record-gcc-switches"

What did you do?

When running go version -m on the latest release of the sumologic open telemetry collector distro.

ex:

$ wget -q https://github.com/SumoLogic/sumologic-otel-collector/releases/download/v0.81.0-sumo-0/otelcol-sumo-0.81.0-sumo-0-linux_amd64
$ go version -m otelcol-sumo-0.81.0-sumo-0-linux_amd64
otelcol-sumo-0.81.0-sumo-0-linux_amd64: go1.20.5

What did you expect to see?

I had expected to see module information as I did for the previous release. E.g.

otelcol-sumo-0.80.0-sumo-0-linux_amd64: go1.20.5
        path    github.com/SumoLogic/sumologic-otel-collector
        mod     github.com/SumoLogic/sumologic-otel-collector   (devel)
        dep     bitbucket.org/atlassian/go-asap/v2      v2.6.0  h1:KiLw3IgbzFLqNxCrVZoKUDJKMxUGoOd+NEOYXGEBhJ0=
        dep     cloud.google.com/go     v0.110.2
        =>      cloud.google.com/go     v0.110.2        h1:sdFPBr6xG9/wkBbfhmUz/JmZC7X6LavQgcrVINrKiVA=
...
        build   -buildmode=exe
        build   -compiler=gc
        build   -tags=netgo
        build   -trimpath=true
        build   CGO_ENABLED=0
        build   GOARCH=amd64
        build   GOOS=linux
        build   GOAMD64=v1
        build   vcs=git
        build   vcs.revision=727558f5fb91fd22e6a5d15f7e488b1bc7789c44
        build   vcs.time=2023-06-30T10:30:38Z
        build   vcs.modified=false

What did you see instead?

A condensed buildinfo summary with only the go build version.
otelcol-sumo-0.81.0-sumo-0-linux_amd64: go1.20.5

Apparent Root Cause

Digging into the suspect binary it appears that the module info expected is embedded in the .go.buildinfo section. It looks to me like there could be an oversight here - where we read the first 64KB of the section, then give up when the encoded module info blob length exceeds the bounds.

@c-kruse c-kruse changed the title debug/buildinfo: module info not read when total section exceeds 64KB debug/buildinfo: module info not read when buildinfo section length exceeds 64KB Jul 29, 2023
@gopherbot
Copy link

Change https://go.dev/cl/514036 mentions this issue: debug/buildinfo: fix module info not read when buildinfo section length exceeds 64KB

@AlexanderYastrebov
Copy link
Contributor

$ wc -c otelcol-sumo-0.81.0-sumo-0-linux_amd64 
186216448 otelcol-sumo-0.81.0-sumo-0-linux_amd64
$ grep -a -b -o -F 'Go buildinf:' otelcol-sumo-0.81.0-sumo-0-linux_amd64 
183476226:Go buildinf:

@AlexanderYastrebov
Copy link
Contributor

Its unfortunate that DataStart() API does not return segment size (maybe its not known in some platforms though hard to imagine) - otherwise it could be used as a limit instead of 64k

// Read the first 64kB of dataAddr to find the build info blob.
// On some platforms, the blob will be in its own section, and DataStart
// returns the address of that section. On others, it's somewhere in the
// data segment; the linker puts it near the beginning.
// See cmd/link/internal/ld.Link.buildinfo.
dataAddr := x.DataStart()
data, err := x.ReadData(dataAddr, 64*1024)

@gopherbot
Copy link

Change https://go.dev/cl/514075 mentions this issue: debug/buildinfo: read full data segment to lookup buildinfo magic

AlexanderYastrebov added a commit to AlexanderYastrebov/go that referenced this issue Jul 29, 2023
@ianlancetaylor
Copy link
Contributor

For the record, it looks like the problem is that the .go.buildinfo section is 66144 bytes, whereas we only read 65536 bytes.

AlexanderYastrebov added a commit to AlexanderYastrebov/go that referenced this issue Jul 29, 2023
@AlexanderYastrebov
Copy link
Contributor

For the record, it looks like the problem is that the .go.buildinfo section is 66144 bytes

yes:

$ objdump -h otelcol-sumo-0.81.0-sumo-0-linux_amd64

otelcol-sumo-0.81.0-sumo-0-linux_amd64:     file format elf64-x86-64

Sections:
Idx Name          Size      VMA               LMA               File off  Algn
  0 .text         04d2f438  0000000000401000  0000000000401000  00001000  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .rodata       02c242f5  0000000005131000  0000000005131000  04d31000  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .typelink     00054518  0000000007d553a0  0000000007d553a0  079553a0  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .itablink     00017e88  0000000007da98c0  0000000007da98c0  079a98c0  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .gosymtab     00000000  0000000007dc1748  0000000007dc1748  079c1748  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .gopclntab    03537c68  0000000007dc1760  0000000007dc1760  079c1760  2**5
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .go.buildinfo 00010260  000000000b2fa000  000000000b2fa000  0aefa000  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  7 .noptrdata    001ebdb2  000000000b30a260  000000000b30a260  0af0a260  2**5
                  CONTENTS, ALLOC, LOAD, DATA
  8 .data         000a08d0  000000000b4f6020  000000000b4f6020  0b0f6020  2**5
                  CONTENTS, ALLOC, LOAD, DATA
  9 .bss          000698e0  000000000b596900  000000000b596900  0b196900  2**5
                  ALLOC
 10 .noptrbss     000163d0  000000000b6001e0  000000000b6001e0  0b2001e0  2**5
                  ALLOC
 11 .note.go.buildid 00000064  0000000000400f9c  0000000000400f9c  00000f9c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

@dr2chase dr2chase added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 31, 2023
@dmitshur dmitshur added this to the Go1.22 milestone Jul 31, 2023
c-kruse added a commit to SumoLogic/sumologic-otel-collector that referenced this issue Aug 1, 2023
Removes the broken debugging step in the build and release CI workflows
showing the included collector components and their go module versions.

This information is baked into the executable. To see components run the
components command `otelcol-sumo components`. If more subtle debugging
is required and knowing the module versions is helpful, there is a
workaround until go1.22 is available with the fix for `go version -m`
(golang/go#61644). Inspect the binary in a
platform specific way.
e.g. `objcopy -O binary -j .go.buildinfo
otelcol-sumo-0.80.0-sumo-0-linux_amd64 buildinfo.txt`

Signed-off-by: Christian Kruse <ctkruse99@gmail.com>
c-kruse added a commit to SumoLogic/sumologic-otel-collector that referenced this issue Aug 1, 2023
Removes the broken debugging step in the build and release CI workflows
showing the included collector components and their go module versions.

This information is baked into the executable. To see components run the
components command `otelcol-sumo components`. If more subtle debugging
is required and knowing the module versions is helpful, there is a
workaround until go1.22 is available with the fix for `go version -m`
(golang/go#61644). Inspect the binary in a
platform specific way.
e.g. `objcopy -O binary -j .go.buildinfo
otelcol-sumo-0.80.0-sumo-0-linux_amd64 buildinfo.txt`

Signed-off-by: Christian Kruse <ctkruse99@gmail.com>
c-kruse added a commit to SumoLogic/sumologic-otel-collector that referenced this issue Aug 2, 2023
Removes the broken debugging step in the build and release CI workflows
showing the included collector components and their go module versions.

This information is baked into the executable. To see components run the
components command `otelcol-sumo components`. If more subtle debugging
is required and knowing the module versions is helpful, there is a
workaround until go1.22 is available with the fix for `go version -m`
(golang/go#61644). Inspect the binary in a
platform specific way.
e.g. `objcopy -O binary -j .go.buildinfo
otelcol-sumo-0.80.0-sumo-0-linux_amd64 buildinfo.txt`

Signed-off-by: Christian Kruse <ctkruse99@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants