Skip to content

x/sys/windows/svc: the service terminated unexpectedly (id 7034) #40074

Closed
@AlexSiLive

Description

@AlexSiLive

What version of Go are you using (go version)?

$ go version
go version go1.14.4 windows/amd64

Does this issue reproduce with the latest release?

Yes.
Go version: go1.14.4
x/sys version: v0.0.0-20200625212154-ddb9806d33ae

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\alex\AppData\Local\go-build
set GOENV=C:\Users\alex\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=*
set GOOS=windows
set GOPATH=C:\Users\alex\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=E:\WorkGo\src\golang.org\x\sys\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\A6473~1.POG\AppData\Local\Temp\go-build406331230=/tmp/go-build -gno-record-gcc-switches
GOROOT/bin/go version: go version go1.14.4 windows/amd64
GOROOT/bin/go tool compile -V: compile version go1.14.4
gdb --version: GNU gdb (GDB) 7.9.1

What did you do?

Problem:
Building a windows service using x/sys/windows/svc on go1.14+ will cause a service to terminate unexpectedly on system shutdown (SERVICE_CONTROL_SHUTDOWN command).

How to reproduce:
Build a default example for x/sys/windows/svc on go1.13 and go1.14. The latter will be terminated unexpectedly and produce a corresponding event in the event log (7034), while the former one will stop just fine.

Remarks:

  • A service can be stopped and started via service manager without an issue, the problem occurs on system shutdown or reboot.
  • Reverting x/sys/windows/svc to initial commits does nothing, i.e. the problem, probably, somewhere in-between go1.13 and go1.14.
    go_svc_7034.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windows

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions