Board index » cppbuilder » Problem with service at Windows shutdown

Problem with service at Windows shutdown


2006-09-12 05:48:15 PM
cppbuilder110
We have a service application which normally starts and stops without
any problems. However when it is stopped as part of a windows shutdown
it generates an error. Something like: Invalid instruction at: 0x...
I have tried logging all steps performed during shutdown of the service
but it never reaches the Stop function of the service. Has anyone
suggestions how I could pinpoint what exactly is happening at the moment
the error occurs? Is it for instance possible to determine from the
address of the instruction on which source line it is?
Thanks,
Eelke
 
 

Re:Problem with service at Windows shutdown

On Tue, 12 Sep 2006 11:48:15 +0200, Eelke < XXXX@XXXXX.COM >
wrote:
Quote
We have a service application which normally starts and stops without
any problems. However when it is stopped as part of a windows shutdown
it generates an error. Something like: Invalid instruction at: 0x...

I have tried logging all steps performed during shutdown of the service
but it never reaches the Stop function of the service. Has anyone
suggestions how I could pinpoint what exactly is happening at the moment
the error occurs? Is it for instance possible to determine from the
address of the instruction on which source line it is?

Thanks,
Eelke
Maybe, your service depends on another service which closes
before yours. I guess that, when the other service closes,
it causes a crash in your service which closes before Windows
tries to stop it. You have to log the main flow(s) of your
service application in order to try to understand if it crashes
in a thread loop which uses some other external resource.
I suggest you to wrap with a try...catch statement, all the
service's threads flows, so to avoid - if possible - the
"access violation condition" when your service closes.
If you aren't able to log the flow in such special condition
like a system shutdown, I would suggest you to use audible
markers (i.e. try to put some Beeps in the catch blocks)
to track the flow with the minimal intrusive impact.
Hope this helps.
Ciao
Giulino
 

Re:Problem with service at Windows shutdown

First items to suspect are timers/threads and other resources that are
constantly used by your sevice. Also, does this service handle the
WM_POWERBROADCAST message? If a service keeps resources open it should
handle this message to peacefully close those resources such as TCP/IP
listeners, database connections, file handles, etc. on PBT_APMSUSPEND and
reopen those resources on PBT_APMRESUMESUSPEND.
- Clayton
 

{smallsort}

Re:Problem with service at Windows shutdown

I am running into the exact same thing. I too have put a log function in
and log all the way through, but have not found the problem. If I do find
it I'll try to share it with you.
"Eelke" < XXXX@XXXXX.COM >wrote in message
Quote
We have a service application which normally starts and stops without
any problems. However when it is stopped as part of a windows shutdown
it generates an error. Something like: Invalid instruction at: 0x...

I have tried logging all steps performed during shutdown of the service
but it never reaches the Stop function of the service. Has anyone
suggestions how I could pinpoint what exactly is happening at the moment
the error occurs? Is it for instance possible to determine from the
address of the instruction on which source line it is?

Thanks,
Eelke
 

Re:Problem with service at Windows shutdown

Quote
Maybe, your service depends on another service which closes
before yours. I guess that, when the other service closes,
it causes a crash in your service which closes before Windows
tries to stop it. You have to log the main flow(s) of your
service application in order to try to understand if it crashes
in a thread loop which uses some other external resource.
I suggest you to wrap with a try...catch statement, all the
service's threads flows, so to avoid - if possible - the
"access violation condition" when your service closes.
If you aren't able to log the flow in such special condition
like a system shutdown, I would suggest you to use audible
markers (i.e. try to put some Beeps in the catch blocks)
to track the flow with the minimal intrusive impact.

Hope this helps.

Thanks I know the cause now. The service uses EPSON OPOS to access POS
printers. When there is no printer configured there is no problem. As
soon as I configure a printer for the service the problem occurs.
However I cannot find any OPOS related service on my machine.
 

Re:Problem with service at Windows shutdown

Clayton Arends wrote:
Quote
First items to suspect are timers/threads and other resources that are
constantly used by your sevice. Also, does this service handle the
WM_POWERBROADCAST message? If a service keeps resources open it should
handle this message to peacefully close those resources such as TCP/IP
listeners, database connections, file handles, etc. on PBT_APMSUSPEND and
reopen those resources on PBT_APMRESUMESUSPEND.

Thanks, this is certainly worth looking into.
Eelke
 

Re:Problem with service at Windows shutdown

On Wed, 13 Sep 2006 11:17:11 +0200, Eelke < XXXX@XXXXX.COM >
wrote:
Quote
Thanks I know the cause now. The service uses EPSON OPOS to access POS
printers. When there is no printer configured there is no problem. As
soon as I configure a printer for the service the problem occurs.

However I cannot find any OPOS related service on my machine.
Uhm, then have a look at others more general services or programs
related to printing. For example, the spool, or others...
Good luck.
Giuliano
 

Re:Problem with service at Windows shutdown

Giuliano wrote:
Quote
On Wed, 13 Sep 2006 11:17:11 +0200, Eelke < XXXX@XXXXX.COM >
wrote:

>Thanks I know the cause now. The service uses EPSON OPOS to access POS
>printers. When there is no printer configured there is no problem. As
>soon as I configure a printer for the service the problem occurs.
>
>However I cannot find any OPOS related service on my machine.

Uhm, then have a look at others more general services or programs
related to printing. For example, the spool, or others...

Printing via OPOS doesn't use the normal printing architecture or GDI.
It is a completely seperate interface implemented with COM.
 

Re:Problem with service at Windows shutdown

On Wed, 13 Sep 2006 16:19:17 +0200, Eelke < XXXX@XXXXX.COM >
wrote:
Quote
Printing via OPOS doesn't use the normal printing architecture or GDI.
It is a completely seperate interface implemented with COM.
Then, if you aren't able to find the related server, service or program
corresponding to OPOS, the only way I can see is that you have to catch
the error condition in your code then quietly absorb it.
HTH
Giuliano