Case of frozen PeekMessage
Recently I was investigating why our application freezes during certain operations. After collecting few dump files, I found that every single time application freezes in quite old code that was written about 20 years ago. Loading documents could be quite long, and some person decided that it would be good idea if user can press Escape and cancel loading. To detect key press, that code calls something like this:
PeekMessage(Msg, CurrentFormHandle, WM_KeyFirst, WM_KeyLast, PM_Remove Or PM_NoYield)
Callstack looks like this:
It looks quite innocent and I do not see any reason why it should hang. After some thinking I came with two theories:
- CurrentFormHandle returns invalid window handle that got reused by some thread that is sleeping
- Code that calls PeekMessage has infinite loop and PeekMessage is just took more time and appears in crash dumps.
Few days ago, I was investigating why one of our servers in cloud stops responding. Basically, it was so bad that we have to force restart server. After some investigation I found that there is IIS server that processes requests and some requests starts external application. And in certain situations, this process starts to allocate a lot of non-paged pool memory. About 100 megabytes per second.
Non-paged pool is special type of memory that is never paged out to disk. It is must be non-paged because at certain times of processing requests paging is unavailable. For example, when interrupt is processing. Also, for example disk driver structures should be non-paged because obviously they cannot be paged out. And in general,
Few days I got a complain from one of the users that he cannot install Windows update. I came and checked it and I can see that it is failed with error code 0x80073712. And then I started to research this problem. On one of the pages I found recommendation to execute following commands:
DISM.exe /Online /Cleanup-image /Scanhealth
DISM.exe /Online /Cleanup-image /Restorehealth
Well, this is simple, and I did execute these commands. Both these commands failed with error “The WOF driver encountered a corruption in the compressed file's Resource Table”. Interesting. Then I started searching for this error and found recommendation to execute following command:
After I executed this command I got this error
It amazes me again and again when you didn’t change anything, but things started to work differently.
That what happened to me recently. Few days ago, I realized that in many places’ popup menu popped up to the left from mouse pointer like on the picture:
This was picture from Outlook, but other Office applications works the same.
At first it looked strange and unusual. I didn’t pay much attention but with time it became a bit annoying. My muscle memory tells me that something is wrong, but brain continues and clicks on menu in unusual place.
Then I started to see it on my work PC. And finally, I decided to
At the beginning I would like to clarify on details of Windows message queue. Many people believe that InvalidateRect function (or any other action that makes your window have update region) will actually post WM_PAINT message into message queue. Similarly, they believe that any mouse movement will leads to insert of WM_MOUSEMOVE (and corresponding messages like WM_HCHITTEST). But in reality, it is quite different (unless there is call to PeekMessage with PM_NOREMOVE). It is not important from processing these messages but very important to understand these details to troubleshoot any problems.
When part of window is invalidated Windows will simply set flag that indicates that window needs painting and that’s it. There is nothing inserted at message queue at all.
Today I accidentally found solution for problem that annoying me for years (literally). And I would like to share it.
Problem was that I cannot print anything at my work from Microsoft Word and Firefox. I use Firefox as my main browser and sometimes (not that often) I have to print from Microsoft Word. And there is no error or similar. Just printer icon pops up for few seconds stating that there is nothing to print and that’s it. I can print from PDF viewer or from another browser but not from Firefox. And it was annoying me a lot. Few times I did something important in Firefox that I have to print, and I cannot open it on
Because I’m IT guy in family usually I have to fix everything related to computers. And once I have to do something on notebook with Windows 10 Home. To be honest I hate working on notebook. They all have different keyboard and trackpads, so it is taking a lot of time to get used to. They are slow and have single small screen. So, I decided to be smart and to use my home computer to connect to that notebook via Remote Desktop. But then I found that Windows 10 Home edition does not have support for Remote Desktop. Huge disappointment. But I didn’t give up. After searching internet, I found nice solution.
There is project https://github.com/stascorp/rdpwrap/blob/master/README.md
I would like to talk about another feature that by some reason was changed in Windows 10 for worst. This is Caps Lock indicator.
Firstly, I would like to setup context here. You as user powered on your computer and waiting for login screen to type your password so you can do something on computer. So finally, login screen is here and you are typing your password.
Let’s see how it looks in previous version of windows. First will be Windows 7 because it is installed on many computers. Here is how Login screen looks when Caps Lock is on:
As you can see you can clearly see that there is yellow
Pretty much from beginning of using Windows 10 I don’t like how it installs updates. Microsoft have to solve two different problems:
- Promptly install important updates that includes critical security fixes
- Install updates in the way that is least interrupting user work
To be honest Microsoft only solved first problem. Second problem works kind of opposite. Let’s discuss it in detail.
In the beginning Windows 10 was just install updates at time when Windows 10 likes. I heard many times from my colleagues that they connected notebook to projector and Windows 10 started to install updates for like 2 hours. It still doing it in cases when notebook was switched off for few weeks. We don’t use notebooks