Discussion:
GetMessage() never comes back
(too old to reply)
Charlie Gibbs
2018-01-04 04:12:24 UTC
Permalink
One of our programs has suddenly stopped working at two of our
customer sites. It comes up successfully, then after a couple
of minutes becomes unresponsive. I've added trace code to the
program and found that it issues a GetMessage() call which never
returns. Since I've set a timer to tick twice a second, that's
the longest it should block, even if no other events occur.

Both of the problem sites are running the latest version of
Windows 10 (build 1709), although a number of other machines
running the same version (including here in the office) are
working fine. The problem machines apparently started acting
up after the update was applied. I've searched the web for
references to KB4054022 and come up with a wide range of
responses, including random horror stories.

Can anyone suggest why GetMessage() might suddenly go away
and never return?
--
/~\ ***@kltpzyxm.invalid (Charlie Gibbs)
\ / I'm really at ac.dekanfrus if you read it the right way.
X Top-posted messages will probably be ignored. See RFC1855.
/ \ HTML will DEFINITELY be ignored. Join the ASCII ribbon campaign!
JJ
2018-01-04 23:29:40 UTC
Permalink
Post by Charlie Gibbs
One of our programs has suddenly stopped working at two of our
customer sites. It comes up successfully, then after a couple
of minutes becomes unresponsive. I've added trace code to the
program and found that it issues a GetMessage() call which never
returns. Since I've set a timer to tick twice a second, that's
the longest it should block, even if no other events occur.
Both of the problem sites are running the latest version of
Windows 10 (build 1709), although a number of other machines
running the same version (including here in the office) are
working fine. The problem machines apparently started acting
up after the update was applied. I've searched the web for
references to KB4054022 and come up with a wide range of
responses, including random horror stories.
Can anyone suggest why GetMessage() might suddenly go away
and never return?
GetMessage() will wait forever and not return if the window handle is still
valid, and there's no window message in the window message queue; or the
window handler never did return due to e.g. deadlock or infinite loop.

I'd suggest outputting a debug string at start and end of each window
message handling. e.g. "WmCreate.Start", "WmCreate.End",
"WaitForSingleObject.Start", "WaitForSingleObject.End", etc. If the
application stalled, you'll know which part of the code which is being
executed.
Charlie Gibbs
2018-01-05 16:02:00 UTC
Permalink
Post by JJ
Post by Charlie Gibbs
Can anyone suggest why GetMessage() might suddenly go away
and never return?
GetMessage() will wait forever and not return if the window handle is still
valid, and there's no window message in the window message queue; or the
window handler never did return due to e.g. deadlock or infinite loop.
I've set a timer to tick every 100 milliseconds. This guarantees that
GetMessage() will never wait longer than that. Or at least it did until
these two machines came along. Could something have killed the timer
without my knowing it? (But why do I not see mouse clicks, etc. either?)
Post by JJ
I'd suggest outputting a debug string at start and end of each window
message handling. e.g. "WmCreate.Start", "WmCreate.End",
"WaitForSingleObject.Start", "WaitForSingleObject.End", etc. If the
application stalled, you'll know which part of the code which is being
executed.
I've been adding trace code and have almost reached that stage. I'll
probably just write a string at the entry point of my window procedure
giving the message code, etc. What I have noticed so far is that a
number of messages come through without having been retrieved by
GetMessage(), particularly to do with program startup and shutdown.
Presumably they get to the window procedure via SendMessage(),
rather than PostMessage().

For now, a workaround seem to be to replace GetMessage() with
a PeekMessage() loop. To avoid hogging the CPU, I call
MsgWaitForMultipleObjects((DWORD) 0, NULL,
TRUE, (DWORD) 100, QS_ALLINPUT);
to sleep for 100 milliseconds before spinning through my
main loop if there's no other activity. (I do a lot of
background processing and other checks in the meantime.)
--
/~\ ***@kltpzyxm.invalid (Charlie Gibbs)
\ / I'm really at ac.dekanfrus if you read it the right way.
X Top-posted messages will probably be ignored. See RFC1855.
/ \ HTML will DEFINITELY be ignored. Join the ASCII ribbon campaign!
Loading...