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/go: default godebug settings not recorded for test binaries #68053

Closed
seankhliao opened this issue Jun 18, 2024 · 2 comments
Closed

cmd/go: default godebug settings not recorded for test binaries #68053

seankhliao opened this issue Jun 18, 2024 · 2 comments
Assignees
Labels
GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@seankhliao
Copy link
Member

Go version

go version devel go1.23-e44fa1c1a9 2024-06-18 15:33:06 +0000 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/user/.cache/go-build'
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT='cacheprog'
GOFLAGS='-trimpath "-ldflags=-s -w"'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/user/.data/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/user/.data/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/user/sdk/gotip'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='path'
GOTOOLDIR='/home/user/sdk/gotip/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.23-e44fa1c1a9 2024-06-18 15:33:06 +0000'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/user/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v3'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/home/user/tmp/testrepo0652/go.mod'
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 -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1549253000=/tmp/go-build -gno-record-gcc-switches'

What did you do?

for a main_test.go (note: should be run without the main.go file below as it can affect the debug settings):

//go:debug panicnil=1
package main_test

import (
	"runtime/debug"
	"testing"
)

func TestFoo(t *testing.T) {
	defer func() {
		t.Fatal(recover())
	}()

	t.Log(debug.ReadBuildInfo())
	panic(nil)
}

running it:

=== RUN   TestFoo
    main_test.go:14: go	devel go1.23-e44fa1c1a9 2024-06-18 15:33:06 +0000 X:cacheprog
        path	go.seankhliao.com/testrepo0652
        mod	go.seankhliao.com/testrepo0652	(devel)	
        build	-buildmode=exe
        build	-compiler=gc
        build	-trimpath=true
        build	DefaultGODEBUG=asynctimerchan=1,gotypesalias=0,tls3des=1,tlskyber=0,x509keypairleaf=0,x509negativeserial=1
        build	CGO_ENABLED=0
        build	GOARCH=amd64
        build	GOEXPERIMENT=cacheprog
        build	GOOS=linux
        build	GOAMD64=v3
         true
    main_test.go:11: <nil>
--- FAIL: TestFoo (0.00s)
FAIL
FAIL	go.seankhliao.com/testrepo0652	0.001s
FAIL

vs

a main.go:

//go:debug panicnil=1
package main

import (
	"fmt"
	"runtime/debug"
)

func main() {
	defer func() {
		fmt.Println(recover())
	}()

	fmt.Println(debug.ReadBuildInfo())
	panic(nil)
}

running it:

go	devel go1.23-e44fa1c1a9 2024-06-18 15:33:06 +0000 X:cacheprog
path	go.seankhliao.com/testrepo0652
mod	go.seankhliao.com/testrepo0652	(devel)	
build	-buildmode=exe
build	-compiler=gc
build	-trimpath=true
build	DefaultGODEBUG=asynctimerchan=1,gotypesalias=0,panicnil=1,tls3des=1,tlskyber=0,x509keypairleaf=0,x509negativeserial=1
build	CGO_ENABLED=0
build	GOARCH=amd64
build	GOEXPERIMENT=cacheprog
build	GOOS=linux
build	GOAMD64=v3
 true
<nil>

What did you see happen?

The test binary did not record a DefaultGODEBUG=panicnil=1, while the setting was clearly in effect (recover nil).

What did you expect to see?

The setting recorded as part of DefaultGODEBUG

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Jun 18, 2024
@matloob matloob self-assigned this Jun 27, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/595961 mentions this issue: cmd/go/internal/load: recompute test variant's build info if necessary

@dmitshur dmitshur added this to the Go1.24 milestone Jul 30, 2024
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants