0

We have a 64bit application running as service on Windows 7 64bit. When we start a service manually, it works fine everytime. When the service is started automatically with system startup, sometimes (like 1 in 10) it fails. Problem is with LoadLibrary function which is in fact the first thing it does. It is a load of our DLL where the most of the code is. I can't reproduce it on my computers, so I am just sending special testing binaries to colleague abroad. I added text outputs to file using unbuffered write operation so I can see exactly where it disappears. There is no crash dump, there is no exception, there is no NULL retrived, it just exits somewhere in LoadLibrary and service is not running after system startup. Our library does not have DllMain, but if I add it, it does not get there (in fail case). I tried delay loading of dependent system libraries, no success. It seems like sometimes something is not yet started in Windows and so the initialization fails, I am not sure. But adding sleep before LoadLibrary does not solve the problem (too late to sleep?). Do you have any ideas what is going on and how to proceed? I am currently going to remove the code from our DLL step by step to remove the lib dependencies one by one to see if in some moment it will start to work. I will be happy to provide additional information when needed.

Martin
  • 165
  • 1
  • 15
  • It is pretty normal for a service to have a dependency on other services to be functional before it can start. There is explicit configuration for that in Windows, Control Panel + Administrative Services, right-click your service, Properties, Dependencies tab. Figuring out what service you need can't be guessed at from the question. But can of course be discovered by trial and error. Have a look-see through the dependencies of other services that do a similar job. – Hans Passant Jan 16 '14 at 11:30
  • Yes, that is possible that we need some dependency which is not yet started in 1 of 10 cases because the order of services is changing. But then I would guess that for example 15 seconds sleep (although not a good solution of course) will help. But it did not. It is very hard to say which service dependency is needed if we don't call any function yet, just load our DLL library. I can also changte behaviour to load it statically, maybe it will tell us more from service log or something. – Martin Jan 16 '14 at 12:12
  • Here you can see our additional library dependencies of our problematic DLL, maybe you will find out which service we need to wait for to load them properly: kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib;secur32.lib;ws2_32.lib;libeay32.lib;icuin.lib;icuuc.lib;zlibstatic.lib – Martin Jan 16 '14 at 12:13

1 Answers1

0

Lenovo RapidBoot Shield app was the reason.

"RapidBoot Shield works by delaying non-critical applications and services to help your system boot faster. However, in some instances, RapidBoot Shield may delay an application and/or service that is critical to the system startup. This can cause the system to boot slower than expected or some applications may be unable to start normally."

Martin
  • 165
  • 1
  • 15