Go version
go1.22rc1
Output of go env in your module/workspace:
set GO111MODULE=off
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\ContainerAdministrator\AppData\Local\go-build
set GOENV=C:\Users\ContainerAdministrator\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\gopath\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\gopath
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=local
set GOTOOLDIR=C:\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22rc1
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
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 -fdebug-prefix-map=C:\Users\CONTAI~1\AppData\Local\Temp\go-build1889816543=/tmp/go-build -gno-record-gcc-switches
What did you do?
I'm filing this on behalf of moby/moby. This came up in a PR attempting to update from go1.21.5 to go1.22rc1: moby/moby#46982. Unfortunately I haven't been able to get it to repro locally by setting up a simpler repro app, and the moby/moby tests are complex enough that I haven't successfully attempted to run them locally. I forked the project and ran experimental changes in GitHub Actions to try things out, for now.
I wrote more details as I went in microsoft/go#1100, but I'll try to summarize it all here. My GitHub Actions runs are at dagood/moby#1.
What did you see happen?
In GitHub CI, this error shows up reliably for a given commit, on each of the 14 jobs that test it per workflow run:
failed to register layer: re-exec error: exit status 1: output: SetFileInformationByHandle \\?\C:\Windows\SystemTemp\hcs2001018820\Files.$wcidirs$: Invalid access to memory location.
I was able to add some code to print a stack trace upon error, and got this:
runtime/debug.Stack()
C:/go/src/runtime/debug/stack.go:24 +0x5e
github.com/docker/docker/vendor/github.com/Microsoft/go-winio.SetFileBasicInfo(0xc00007d550, 0xf?)
C:/gopath/src/github.com/docker/docker/vendor/github.com/Microsoft/go-winio/fileinfo.go:49 +0x85
github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/internal/wclayer.(*legacyLayerWriter).Add(0xc000b02680, {0xc000859410, 0x5}, 0xc0004a1350)
C:/gopath/src/github.com/docker/docker/vendor/github.com/Microsoft/hcsshim/internal/wclayer/legacy.go:697 +0xb54
github.com/docker/docker/daemon/graphdriver/windows.writeLayerFromTar({0x2b80e[40](https://github.com/dagood/moby/actions/runs/7414601797/job/20176251891#step:12:41), 0xc00007c058}, {0x2bae120, 0xc000097d60}, {0xc00087a[48](https://github.com/dagood/moby/actions/runs/7414601797/job/20176251891#step:12:49)0, 0x80})
C:/gopath/src/github.com/docker/docker/daemon/graphdriver/windows/windows.go:7[54](https://github.com/dagood/moby/actions/runs/7414601797/job/20176251891#step:12:55) +0x312
github.com/docker/docker/daemon/graphdriver/windows.writeLayer({0x2b80e40, 0xc00007c058}, {0xc00004aa00, 0x3f}, {0xc00004aa80, 0x40}, {0xc0000920b0, 0x1, 0x1})
C:/gopath/src/github.com/docker/docker/daemon/graphdriver/windows/windows.go:831 +0x2aa
github.com/docker/docker/daemon/graphdriver/windows.writeLayerReexec()
C:/gopath/src/github.com/docker/docker/daemon/graphdriver/windows/windows.go:792 +0x75
github.com/docker/docker/pkg/reexec.Init(...)
C:/gopath/src/github.com/docker/docker/pkg/reexec/reexec.go:30
main.main()
C:/gopath/src/github.com/docker/docker/cmd/dockerd/docker.go:75 +0x196
Because the the error itself mentions SetFileInformationByHandle, it seems like this must be related to 549256: internal/syscall/windows: fix the signature of SetFileInformationByHandle (it involves the same function name and the CL and error are both new in go1.22rc1). However, based on the stack trace, I'm not sure it's linked at all. The CL changes internal/syscall/windows like this:
- //sys SetFileInformationByHandle(... buf uintptr, bufsize uint32) ...
+ //sys SetFileInformationByHandle(... buf unsafe.Pointer, bufsize uint32) ...
But fileinfo.go#L38-L55 uses x/sys/windows's implementation, which isn't like either of those, accepting *byte:
//sys SetFileInformationByHandle(... inBuffer *byte, inBufferLen uint32) ...
func SetFileBasicInfo(f *os.File, bi *FileBasicInfo) error {
if err := windows.SetFileInformationByHandle(
windows.Handle(f.Fd()),
windows.FileBasicInfo,
(*byte)(unsafe.Pointer(bi)),
uint32(unsafe.Sizeof(*bi)),
); err != nil {
return &os.PathError{Op: "SetFileInformationByHandle", Path: f.Name(), Err: err}
}
runtime.KeepAlive(f)
return nil
}
My next experiment was to try putting %#v of bi in the error message to see if something's special about the values. That could perhaps help me repro this locally with a simpler program. However... adding a fmt.*f causes the error to stop happening!
So, I thought that somehow bi wasn't being kept alive, and that's why trying to format it made it work. I removed the formatting code and added runtime.KeepAlive(bi) after runtime.KeepAlive(f) instead. But the error shows up in this case.
This makes me think the compiler is making some decision differently in go1.22rc1 than it did in go1.21.5, leading to this error when combined with this code.
Maybe it's an issue with the library, but I'm not sure how to properly investigate that, and understanding what changed in go1.22rc1 to make this start showing up will help narrow that down at the very least.
What did you expect to see?
No error.
Go version
go1.22rc1
Output of
go envin your module/workspace:What did you do?
I'm filing this on behalf of moby/moby. This came up in a PR attempting to update from go1.21.5 to go1.22rc1: moby/moby#46982. Unfortunately I haven't been able to get it to repro locally by setting up a simpler repro app, and the moby/moby tests are complex enough that I haven't successfully attempted to run them locally. I forked the project and ran experimental changes in GitHub Actions to try things out, for now.
I wrote more details as I went in microsoft/go#1100, but I'll try to summarize it all here. My GitHub Actions runs are at dagood/moby#1.
What did you see happen?
In GitHub CI, this error shows up reliably for a given commit, on each of the 14 jobs that test it per workflow run:
I was able to add some code to print a stack trace upon error, and got this:
Because the the error itself mentions SetFileInformationByHandle, it seems like this must be related to 549256: internal/syscall/windows: fix the signature of SetFileInformationByHandle (it involves the same function name and the CL and error are both new in go1.22rc1). However, based on the stack trace, I'm not sure it's linked at all. The CL changes
internal/syscall/windowslike this:But fileinfo.go#L38-L55 uses
x/sys/windows's implementation, which isn't like either of those, accepting*byte:My next experiment was to try putting
%#vofbiin the error message to see if something's special about the values. That could perhaps help me repro this locally with a simpler program. However... adding afmt.*fcauses the error to stop happening!So, I thought that somehow
biwasn't being kept alive, and that's why trying to format it made it work. I removed the formatting code and addedruntime.KeepAlive(bi)afterruntime.KeepAlive(f)instead. But the error shows up in this case.This makes me think the compiler is making some decision differently in go1.22rc1 than it did in go1.21.5, leading to this error when combined with this code.
Maybe it's an issue with the library, but I'm not sure how to properly investigate that, and understanding what changed in go1.22rc1 to make this start showing up will help narrow that down at the very least.
What did you expect to see?
No error.