I'm seeing weird error with my Windows service program. My service program calls StartServiceCtrlDispatcher()
at the very beginning of its main()
, but it sometime fails with 1063 (ERROR_FAILED_SERVICE_CONTROLLER_CONNECT)
.
I know that this error occurs if the user starts program manually (as a console program). But, it's not the case. I added a code to check the parent process of the service program when this error occurs, and it tells services.exe is the parent process (I think it's safe to assume that my program was properly started by SCM).
Unfortunately, this error does not reproduce on my dev machine and cannot debug it by myself, but the error logs captured on user systems tells:
StartServiceCtrlDispatcher()
stalls for about a second before it returns with fail.Has anyone seen similar error? If so, what was the cause of the error?
As you can already see from the absence of answers and anything on google, the problem isn't common. I believe the problem is in your service, AND it is in code executed from process's start to StartServiceCtrlDispatcher()
, AND most likely it takes some form of corrupting system resources, likely heap or HANDLE
's.
You can be sorry to hear this, but I'm not going to have a magic answer to your problems. Instead, I can suggest some troubleshooting.
Microsoft Application Verifier is invaluable in finding corruption. I suggest that you:
Basics\Heaps
for the first time.Basics\Handles
. Unlike Basics\Heaps
, this can sometimes fire "false positives" - mistakes in code that doesn't hurt much. Anyway, since you're on the hunt, you'd better fix everything you can find. I'm mostly worried about double-freeing a HANDLE
or something like that. Freeing a Service manager HANDLE
by mistake can surely lead to your problem.Basics\*
, but I don't think that will help.main()
and StartServiceCtrlDispatcher()
, and any global constructors you can have. Look for potential buffer overflows and errors with HANDLE
's.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With