-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: the service terminated unexpectedly (id 7034) #40074
Comments
@gopherbot add OS-Windows |
Thank you for reporting the issue and the steps to reproduce the problem. Yes, I can see shutdown event sent for service compiled with go1.13.12, but not with current tip. We need to try to use git bisect command to find commit that broken the code (it is, probably, https://go-review.googlesource.com/c/go/+/187739/ ). Unfortunately I don't have time to run bisect now, but I will do it when I have time. Unless someone beats me to it. Alex |
Just a quick update. |
I was able to make a dirty fix for this without modifying runtime by adding signal.Notify handling to a wrapping package.
` Please note, that following didn't work for me (unless I'm doing something wrong):
` |
Change https://golang.org/cl/242378 mentions this issue: |
Cool. Thanks for checking that. We just need to come up with a solution here. Alex |
I'm not @AlexSiLive :) |
Change https://golang.org/cl/242280 mentions this issue: |
This issue is with golang.org/x/sys/windows/svc package. The problem was introduced in https://go-review.googlesource.com/c/go/+/187739/ After the CL 187739, every Windows service would not receive "shutdown" event. When computer is shutdown, Go service just exits, instead of handling "shutdown" event. @zx2c4 sent a fix for this issue And the fix is in runtime package. Both Jason and I think the fix should be back-ported to Go 1.14 (Go 1.13 is good). Should we submit CL 242280 now? Should we wait for tree to be opened first? Do you agree CL 242280 should be back-ported? There is some risk involved. Here, in particular, we don't even have a test for the fix - you need to reboot computer to test our fix. What do you think? Thank you. Alex |
@aclements, most of the discussion about this is in #40167 |
Change https://golang.org/cl/243597 mentions this issue: |
Change https://golang.org/cl/244957 mentions this issue: |
Change https://golang.org/cl/244958 mentions this issue: |
Change https://golang.org/cl/244959 mentions this issue: |
Sorry for the churn. The two backports are https://golang.org/cl/244958 and https://golang.org/cl/244959. |
The service handler needs to handle CTRL+C-like events -- including those sent by the service manager itself -- using the default Windows implementation if no signal handler from Go is already listening to those events. Ordinarily, the signal handler would call exit(2), but we actually need to allow this to be passed onward to the service handler. So, we detect if we're in a service and skip calling exit(2) in that case, just like we do for shared libraries. Updates #40167. Updates #40074. Fixes #40412. Change-Id: Ia77871737a80e1e94f85b02d26af1fd2f646af96 Reviewed-on: https://go-review.googlesource.com/c/go/+/244959 Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
The service handler needs to handle CTRL+C-like events -- including those sent by the service manager itself -- using the default Windows implementation if no signal handler from Go is already listening to those events. Ordinarily, the signal handler would call exit(2), but we actually need to allow this to be passed onward to the service handler. So, we detect if we're in a service and skip calling exit(2) in that case, just like we do for shared libraries. Updates #40167. Updates #40074. Fixes #40411. Change-Id: Ia77871737a80e1e94f85b02d26af1fd2f646af96 Reviewed-on: https://go-review.googlesource.com/c/go/+/244958 Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
What version of Go are you using (
go version
)?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
OutputWhat 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:
go_svc_7034.zip
The text was updated successfully, but these errors were encountered: