BUG: ATL EXE Server Based on CComAutoThreadModule May Hang on RegistrationID: Q202128
|
An ATL EXE server based on CComAutoThreadModule<> can hang when being registered or unregistered.
CComAutoThreadModule<>::Init() called in WinMain() creates a thread pool (by default 4 threads). The destructor of global CComAutoThreadModule makes certain these threads terminate before the process terminates. This happens by posting a WM_QUIT message to each of the threads in the thread pool and calling WaitForSingleObject() on the thread handle. The threads are scheduled such that the threads in the pool may not have called GetMessage() and so the message queue is not created. This causes the PostThreadMessage() to fail. Hence, the threads in the pool do not terminate and WaitForSingleObject() waits infinitely for the threads to terminate.
In the Altcom.h file, inside the vc98\atl\include directory of destructor in the CComAutoThreadModule function replace the following code:
::PostThreadMessage(m_pApartments[i].m_dwThreadID, WM_QUIT, 0, 0);
while (::PostThreadMessage(m_pApartments[i].m_dwThreadID, WM_QUIT,
0, 0) == 0) ::Sleep(100);
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
Additional query words: kbDSupport
Keywords : kbATL kbCOMt kbThread kbVC600 kbVC600bug kbATL300 kbATL300bug
Version : WINDOWS:3.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: April 22, 1999