golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.83k stars 17.51k forks source link

cmd/go: in 1.23rc2, TestScript fails on Windows when GOEXPERIMENT is set: "go was invoked but no counters were incremented" #68579

Open dagood opened 1 month ago

dagood commented 1 month ago

Go version

go version go1.23rc2 windows/amd64

Output of go env in your module/workspace:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\dagood\AppData\Local\go-build
set GOENV=C:\Users\dagood\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=aliastypeparams
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\dagood\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\dagood\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\git\golang-1.23
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=local
set GOTOOLDIR=C:\git\golang-1.23\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.23rc2
set GODEBUG=
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\dagood\AppData\Roaming\go\telemetry
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\git\golang-1.23\src\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\dagood\AppData\Local\Temp\go-build516846017=/tmp/go-build -gno-record-gcc-switches

What did you do?

In pwsh, in src:

$ .\make.bat
$ $env:GOEXPERIMENT='aliastypeparams'
$ ..\bin\go test cmd/go -run TestScript/mod_tidy_newroot

(Many other TestScripts will fail in this situation because they share the telemetry check, but I chose this one as an example with relatively low output.)

What did you see happen?

vcs-test.golang.org rerouted to http://127.0.0.1:56505
https://vcs-test.golang.org rerouted to https://127.0.0.1:56506
go test proxy running at GOPROXY=http://127.0.0.1:56507/mod
--- FAIL: TestScript (0.25s)
    --- FAIL: TestScript/mod_tidy_newroot (2.31s)
        script_test.go:135: 2024-07-24T21:21:42Z
        script_test.go:137: $WORK=C:\Users\dagood\AppData\Local\Temp\cmd-go-test-172627406\tmpdir3320471896\mod_tidy_newroot2053734181
        script_test.go:159:
            # https://golang.org/issue/45952: 'go mod tidy' in an eager module failed due
            # to an erroneous check on root completeness.
            #
            # Per the issue report:
            # > It may have to do with:
            # >
            # > package A imports package B in go.mod, which imports package C in its own go.mod
            # > package A drops direct dependency on package B …
            #
            # We infer from that that package C is still needed by some other indirect
            # dependency, and must be at a higher version than what is required by that
            # dependency (or else no new root would be needed). An additional package D
            # in its own module satisfies that condition, reproducing the bug. (2.269s)
        script_test.go:401: go was invoked but no counters were incremented
FAIL
FAIL    cmd/go  6.004s
FAIL

If I don't limit the test run, many other test scripts fail with the same error script_test.go:401: go was invoked but no counters were incremented.

I got the same bad result with $env:GOEXPERIMENT='arenas'.

What did you expect to see?

ok      cmd/go  6.191s

I got this result with go version devel go1.24-792a261303 Wed Jul 24 18:59:46 2024 +0000 windows/amd64 on the same machine.

gabyhelp commented 1 month ago

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

dagood commented 1 month ago

If I delete VERSION, rerun make.bat, and then ..\bin\go test cmd/go -run TestScript/mod_tidy_newroot, the test passes.

dmitshur commented 1 month ago

CC @matloob, @findleyr.

matloob commented 1 month ago

I can reproduce on Windows (though not on macOS) so this might be a Windows-specific issue. I'll try to find a fix.

dagood commented 1 month ago

It didn't happen for me on Linux either, I agree it's probably specific to running on Windows.

matloob commented 1 month ago

cc @findleyr

Running the test on windows it seems to be writing counters to a file called C:\Users\matloob\AppData\Local\Temp\cmd-go-test-2272649242\tmpdir1967189891\mod_tidy_newroot3105556267\telemetry\local\go@go1.23rc2 X:aliastypeparams-go1.23rc2 X:aliastypeparams-windows-amd64-2024-08-02.v1.count

We get the following error trying to open the file: The filename, directory name, or volume label syntax is incorrect.

I think that we expect that when the version name is not a devel version, say "go1.23rc2" that the version name doesn't contain anything other than the version name, but with GOEXPERIMENTS it adds the experiment names to the version. I think we should probably? mark those as devel.

alexbrainman commented 1 month ago

to a file called C:\Users\matloob\AppData\Local\Temp\cmd-go-test-2272649242\tmpdir1967189891\mod_tidy_newroot3105556267\telemetry\local\go@go1.23rc2 X:aliastypeparams-go1.23rc2 X:aliastypeparams-windows-amd64-2024-08-02.v1.count

You should avoid using column ":" in the Windows file names. Just in case you did not know that.

Alex