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

x/sys/windows: improper fix to previous report #65378

Closed
derekwbrown opened this issue Jan 30, 2024 · 2 comments
Closed

x/sys/windows: improper fix to previous report #65378

derekwbrown opened this issue Jan 30, 2024 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Milestone

Comments

@derekwbrown
Copy link

Go version

1.21.5

Output of go env in your module/workspace:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\db\AppData\Local\go-build
set GOENV=C:\Users\db\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=c:\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=c:\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go\1.21.5\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=c:\go\1.21.5\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\src\datadog-windows-procmon\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\db\AppData\Local\Temp\go-build3031818741=/tmp/go-build -gno-record-gcc-switches

What did you do?

Submitted #65365
But the fix that was submitted creates different problems, including when race is not enabled.

What did you see happen?

Opening a new issue because it's not clear if follow up comments after an issue is closed are seen.
I submitted issue #65365

However, the fix creates additional problems.
the fix supplies the optional parameter lpNumberOfBytesRead even when race is not set, and when the caller provided null.

However, the documentation explicitly says don't do that:

 Use NULL for this parameter if this is an asynchronous operation to avoid potentially erroneous results.

So, as a result of the fix, the library now introduces indeterminant behavior into calling code, even when race is not enabled.

What did you expect to see?

A fix that doesn't break additional code.

Suggest the conditional become

func ReadFile(fd Handle, p []byte, done *uint32, overlapped *Overlapped) error {
	err := readFile(fd, p, done, overlapped)
 	if raceenabled && done {
		if *done > 0 {
			raceWriteRange(unsafe.Pointer(&p[0]), int(*done))
		}
       }
 	return err
 }

Or similar, since the value of lpNumberOfBytesRead is not valid in the case where an overlapped operation has been initiated.

@gopherbot gopherbot added this to the Unreleased milestone Jan 30, 2024
@mknyszek mknyszek changed the title x/sys/windows improper fix to previous report x/sys/windows: improper fix to previous report Jan 30, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jan 30, 2024
@mknyszek
Copy link
Contributor

CC @qmuntal @bcmills

@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 30, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/559502 mentions this issue: Revert "windows: support nil done parameter in ReadFile and WriteFile"

@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. FixPending Issues that have a fix which has not yet been reviewed or submitted. labels Jan 30, 2024
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FixPending Issues that have a fix which has not yet been reviewed or submitted. NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Projects
None yet
Development

No branches or pull requests

5 participants