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/svc: wrong handling of evdata parameter #65832

Open
mxmauro opened this issue Feb 21, 2024 · 1 comment
Open

x/sys/windows/svc: wrong handling of evdata parameter #65832

mxmauro opened this issue Feb 21, 2024 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mxmauro
Copy link

mxmauro commented Feb 21, 2024

Go version

go1.21.4 windows/amd64

Output of go env in your module/workspace:

set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Blaster128\go\pkg\mod
set GOOS=windows
set GOPATH=C:\Users\Blaster128\go
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Lenguaje\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Lenguaje\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.4
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
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:\Windows\TEMP\go-build1578704517=/tmp/go-build -gno-record-gcc-switches

What did you do?

I was trying to handle svc.SessionChange when the event type is windows.WTS_SESSION_LOGON or windows.WTS_SESSION_LOGOFF.

The problem is c.EventData points to a windows.WTSSESSION_NOTIFICATION structure but, by the time the Handler is called, svc's ctlHandler already returned and the data may be invalid.

What did you see happen?

It is hard to reproduce a problem because the memory, usually, is still valid.

What did you expect to see?

I expect the data pointed by the EventData field to be captured and copied locally into the ctlEvent object before being sent through the channel to the main loop.

@seankhliao seankhliao changed the title golang.org/x/sys/windows/svc: wrong handling of evdata parameter x/sys/windows/svc: wrong handling of evdata parameter Feb 21, 2024
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 21, 2024
@seankhliao
Copy link
Member

cc @golang/windows

@gopherbot gopherbot added this to the Unreleased milestone Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants