Skip to content

runtime/debug: ReadBuildInfo returns !ok #51915

@alienorlatour

Description

@alienorlatour

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

$ go version
go version go1.18 linux/amd64

Does this issue reproduce with the latest release?

It only reproduces with the lastest release.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="~/.cache/go-build"
GOENV="~/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="..."
GONOPROXY="..."
GONOSUMDB="..."
GOOS="linux"
GOPATH="..."
GOPRIVATE="..."
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.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1839977099=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I am using the debug package in a unit testing environment:

import "runtime/debug"

func Test_modinfo(t *testing.T) {
	_, ok := debug.ReadBuildInfo()
	if ok {
		t.Fail()
	}
}

What did you expect to see?

The test passes in version 1.17

What did you see instead?

The test does not pass in version 1.18

My investigation so far

https://github.com/golang/go/blob/master/src/runtime/debug/mod.go#L15
Apparently, the modinfo() method returns exactly 32 bytes in 1.18, and 0 in 1.17, leading to a different behaviour.

It happens both on my machine and in my CI docker image which uses go latest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions