Hi Carsten, I did not notice you move the post to gsl mail list, I repost the new information there too
Thanks -Huai Dong On Thu, Dec 3, 2009 at 3:43 PM, Huaidong Qiu <[email protected]> wrote: > Hi all, > > I think I found the reason for the freeze. > If DropTarget::initialize called from a STA thread, the wait function > WaitForSingleObject() should not be used, because this wait will block the > message pumping of the thread, all COM calls will be blocked, this could > lead to a freeze. > > Quote from the API document of WaitForSingleObject: > > Use caution when calling the wait functions and code that directly or > indirectly creates windows. If a thread creates any windows, it must process > messages. Message broadcasts are sent to all windows in the system. A thread > that uses a wait function with no time-out interval may cause the system to > become deadlocked. Two examples of code that indirectly creates windows are > DDE and the > *CoInitialize*<http://msdn.microsoft.com/en-us/library/ms678543%28VS.85%29.aspx>function. > Therefore, if you have a thread that creates windows, use > *MsgWaitForMultipleObjects*<http://msdn.microsoft.com/en-us/library/ms684242%28VS.85%29.aspx>or > *MsgWaitForMultipleObjectsEx*<http://msdn.microsoft.com/en-us/library/ms684245%28VS.85%29.aspx>, > rather than *WaitForSingleObject*. > > > I think we should use CoWaitForMultipleHandles(), which is a wrapper for > MsgWaitForMultipleObjects(), after I switched to CoWaitForMultipleHandles(), > app did not freeze in DropTarget::initialize anymore. > > Any idea about this. > > Thanks > > -Huai Dong > > > On Mon, Nov 30, 2009 at 5:00 PM, Carsten Driesner < > [email protected]> wrote: > >> Huaidong Qiu wrote: >> >>> Hi Carsten, >>> >>> Yes, you are right, the possibility of OleInitialize failure is very low. >>> There wasn't two thread calling DropTarget::initialize, and the calling >>> thread is not main thread, I just think DropTarget::initialize call >>> should >>> return already. >>> >>> But there are another possibility, the freeze main be caused by the main >>> thread, looks like some recursive calling going on. Could give some >>> suggestion about this. >>> >>> BTW: this comes from a crash report. >>> >>> >> Hi Huaidong, >> >> This is a completely different call stack and you are right that it looks >> like a strange recursion problem. I am not very familiar with this part of >> OpenOffice.org as the responsible code resides in VCL which is maintained by >> the gsl team. Hopefully someone from the team can give us some more >> information about this strange stack. >> >> Regards, >> Carsten >> >> Thanks >>> >>> >>> function name: void __cdecl ImplSalYieldMutexAcquireWithWait(void) >>> function name: long __cdecl ImplHandleSalObjKeyMsg(struct HWND__ >>> *,unsigned int,unsigned int,long) >>> function name: long __stdcall SalFrameWndProc(struct HWND__ >>> *,unsigned >>> int,unsigned int,long,int &) >>> function name: long __stdcall SalFrameWndProcW(struct HWND__ >>> *,unsigned >>> int,unsigned int,long) >>> function name: int __cdecl ImplGetMessage(struct tagMSG *,struct >>> HWND__ >>> *,unsigned int,unsigned int) >>> function name: void __cdecl ImplSalYieldMutexAcquireWithWait(void) >>> function name: long __cdecl ImplHandleSalObjKeyMsg(struct HWND__ >>> *,unsigned int,unsigned int,long) >>> function name: long __stdcall SalFrameWndProc(struct HWND__ >>> *,unsigned >>> int,unsigned int,long,int &) >>> function name: long __stdcall SalFrameWndProcW(struct HWND__ >>> *,unsigned >>> int,unsigned int,long) >>> function name: int __cdecl ImplGetMessage(struct tagMSG *,struct >>> HWND__ >>> *,unsigned int,unsigned int) >>> function name: void __cdecl ImplSalYieldMutexAcquireWithWait(void) >>> function name: long __cdecl ImplHandleSalObjKeyMsg(struct HWND__ >>> *,unsigned int,unsigned int,long) >>> function name: long __stdcall SalFrameWndProc(struct HWND__ >>> *,unsigned >>> int,unsigned int,long,int &) >>> function name: long __stdcall SalFrameWndProcW(struct HWND__ >>> *,unsigned >>> int,unsigned int,long) >>> function name: int __cdecl ImplGetMessage(struct tagMSG *,struct >>> HWND__ >>> *,unsigned int,unsigned int) >>> function name: void __cdecl ImplSalYieldMutexAcquireWithWait(void) >>> function name: public: virtual void __thiscall >>> WinSalInstance::Yield(bool,bool) >>> function name: public: static void __cdecl Application::Yield(bool) >>> function name: public: static void __cdecl Application::Execute(void) >>> function name: unsigned char __cdecl ImplSVMain(void) >>> function name: unsigned char __cdecl SVMain(void) >>> >>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> >
