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

runtime/debug: ReadBuildInfo returns !ok #51915

Closed
alienorlatour opened this issue Mar 24, 2022 · 3 comments
Closed

runtime/debug: ReadBuildInfo returns !ok #51915

alienorlatour opened this issue Mar 24, 2022 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@alienorlatour
Copy link

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.

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 24, 2022
@seankhliao
Copy link
Member

I can't reproduce it, with

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

The output for 1.17.8 and 1.18 are:

main » go1.17.8 test
--- FAIL: Test_modinfo (0.00s)
    main_test.go:11: &{go.seankhliao.com/testrepo-833 {go.seankhliao.com/testrepo-833 (devel)  <nil>} []}
FAIL
exit status 1
FAIL	go.seankhliao.com/testrepo-833	0.001s
main » go1.18 test   
--- FAIL: Test_modinfo (0.00s)
    main_test.go:11: go	go1.18
        path	go.seankhliao.com/testrepo-833
        mod	go.seankhliao.com/testrepo-833	(devel)	
        build	-compiler=gc
        build	CGO_ENABLED=1
        build	CGO_CFLAGS=
        build	CGO_CPPFLAGS=
        build	CGO_CXXFLAGS=
        build	CGO_LDFLAGS=
        build	GOARCH=amd64
        build	GOOS=linux
        build	GOAMD64=v1
        build	vcs=git
        build	vcs.revision=ce9d04da5cfff9b82b1961bc82ae0482841f799a
        build	vcs.time=2022-03-24T14:30:06Z
        build	vcs.modified=true
        
FAIL
exit status 1
FAIL	go.seankhliao.com/testrepo-833	0.001s

Which looks to be working as intended

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 25, 2022
@mknyszek mknyszek changed the title affected/package: runtime/debug runtime/debug: ReadBuildInfo returns !ok Mar 25, 2022
@mknyszek mknyszek added this to the Backlog milestone Mar 25, 2022
@slavabobik
Copy link

On my env I could reproduce that

go version
go version go1.18 darwin/amd64

@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Apr 24, 2023
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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants