Maybe the DropTarget::initialize calling thread does not have a message
loop, but DropTarget::initialize does create a COM object:
       m_pDropTarget= new IDropTargetImpl( *static_cast<DropTarget*>( this)
);
This means the calling thread needs a message loop.

This freeze is hard to reproduce in our system, I think maybe because the
COM calls into the COM object of the thread during the waiting period are
very rare, but the freeze could happen.

On Fri, Dec 4, 2009 at 12:36 AM, Huaidong Qiu <[email protected]> wrote:

> Hi Carsten,
>
> Here is the crash report.
>
> Get pdb_version from commanline: 20091103.1700
> pdb_version: 20091103.1700 pdb_file:
> ./Sym_Sym2.0_beta1_20091103.1700_pdbfiles.zip
> zzz
> Stack frame position [0]
> 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:     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)
> function name:     _soffice_main
> function name:     _main
> function name:     _winm...@16
> Stack frame position [0]
> function name:     _rtl_cache_free
> Stack frame position [0]
> Stack frame position [0]
> function name:     public: int __thiscall
> WinLmrInstance::RunPrefetching(void)
> function name:     unsigned long __stdcall runWinLmrPrefetching(void *)
> Stack frame position [0]
> function name:     _osl_waitCondition
> function name:     public: virtual enum vos::ICondition::TResult __cdecl
> vos::OCondition::wait(struct TimeValue const *)
> function name:     protected: virtual void __cdecl
> vos::OTimerManager::run(void)
> function name:     void __cdecl vos::threadWorkerFunction_impl(void *)
> function name:     _osl_getGlobalMutex
> Stack frame position [0]
> function name:     _osl_acceptPipe
> function name:     public: enum vos::OPipe::TPipeError __cdecl
> vos::OPipe::accept(class vos::OStreamPipe &)
> function name:     protected: virtual void __cdecl
> desktop::OfficeIPCThread::run(void)
> function name:     void __cdecl vos::threadWorkerFunction_impl(void *)
> function name:     _osl_getGlobalMutex
> Stack frame position [0]
> function name:     _osl_acceptPipe
> function name:     public: void __cdecl desktop::Acceptor::run(void)
> function name:     _osl_getGlobalMutex
> Stack frame position [0]
> function name:     _osl_waitCondition
> function name:     public: virtual void __cdecl
> bridges_urp::OWriterThread::run(void)
> function name:     _threadFunc
> function name:     _osl_getGlobalMutex
> Stack frame position [0]
> function name:     _osl_receivePipe
> function name:     _osl_readPipe
> function name:     private: unsigned char __thiscall
> bridges_urp::OReaderThread::readBlock(long *)
> function name:     private: virtual void __cdecl
> bridges_urp::OReaderThread::run(void)
> function name:     _threadFunc
> function name:     _osl_getGlobalMutex
> Stack frame position [0]
> function name:     private: unsigned int __thiscall
> CMtaOleClipboard::run(void)
> function name:     private: static unsigned int __stdcall
> CMtaOleClipboard::oleThreadProc(void *)
> Stack frame position [0]
> function name:     private: static unsigned int __stdcall
> CMtaOleClipboard::clipboardChangedNotifierThreadProc(void *)
> Stack frame position [0]
> function name:     unsigned long __stdcall DndTargetOleSTAFunc(void *)
> Stack frame position [0]
> Stack frame position [0]
> function name:     public: virtual void __cdecl
> DropTarget::initialize(class com::sun::star::uno::Sequence<class
> com::sun::star::uno::Any> const &)
> function name:     public: virtual class
> com::sun::star::uno::Reference<class com::sun::star::uno::XInterface>
> __cdecl
> cppu::OSingleFactoryHelper::createInstanceWithArgumentsAndContext(class
> com::sun::star::uno::Sequence<class com::sun::star::uno::Any> const &,class
> com::sun::star::uno::Reference<class com::sun::star::uno::XComponentContext>
> const &)
> function name:     public: virtual class
> com::sun::star::uno::Reference<class com::sun::star::uno::XInterface>
> __cdecl
> cppu::OFactoryComponentHelper::createInstanceWithArgumentsAndContext(class
> com::sun::star::uno::Sequence<class com::sun::star::uno::Any> const &,class
> com::sun::star::uno::Reference<class com::sun::star::uno::XComponentContext>
> const &)
> function name:     public: virtual class
> com::sun::star::uno::Reference<class com::sun::star::uno::XInterface>
> __cdecl
> cppu::ORegistryFactoryHelper::createInstanceWithArgumentsAndContext(class
> com::sun::star::uno::Sequence<class com::sun::star::uno::Any> const &,class
> com::sun::star::uno::Reference<class com::sun::star::uno::XComponentContext>
> const &)
> function name:     public: virtual class
> com::sun::star::uno::Reference<class
> com::sun::star::datatransfer::dnd::XDragSource> __thiscall
> Window::GetDragSource(void)
> function name:     public: virtual class
> com::sun::star::uno::Reference<class
> com::sun::star::datatransfer::dnd::XDropTarget> __thiscall
> Window::GetDropTarget(void)
> function name:     public: void __thiscall Window::SetParent(class Window
> *)
> function name:     public: virtual bool __thiscall
> sd::ViewShell::RelocateToParentWindow(class Window *)
> function name:     public: bool __thiscall
> sd::slidesorter::SlideSorter::RelocateToWindow(class Window *)
> function name:     public: virtual unsigned char __cdecl
> sd::framework::ViewShellWrapper::relocateToAnchor(class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResource> const &)
> function name:     private: void __thiscall
> sd::framework::BasicViewFactory::ReleaseView(class boost::shared_ptr<class
> sd::framework::BasicViewFactory::ViewDescriptor> const &,bool)
> function name:     public: virtual void __cdecl
> sd::framework::BasicViewFactory::releaseResource(class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResource> const &)
> function name:     private: void __thiscall
> sd::framework::ConfigurationControllerResourceManager::DeactivateResource(class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const &,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XConfiguration> const &)
> function name:     class boost::_bi::bind_t<void,class
> boost::_mfi::mf2<void,class
> sd::framework::ConfigurationControllerResourceManager,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const &,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XConfiguration> const &>,class
> boost::_bi::list3<class boost::_bi::value<class
> sd::framework::ConfigurationControllerResourceManager *>,class
> boost::arg<1>,class boost::_bi::value<class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XConfiguration> > > > __cdecl
> _STL::for_each<class _STL::reverse_iterator<class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const *,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId>,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const &,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const *,int>,class
> boost::_bi::bind_t<void,class boost::_mfi::mf2<void,class
> sd::framework::ConfigurationControllerResourceManager,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const &,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XConfiguration> const &>,class
> boost::_bi::list3<class boost::_bi::value<class
> sd::framework::ConfigurationControllerResourceManager *>,class
> boost::arg<1>,class boost::_bi::value<class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XConfiguration> > > > >(class
> _STL::reverse_iterator<class com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const *,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId>,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const &,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const *,int>,class
> _STL::reverse_iterator<class com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const *,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId>,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const &,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const *,int>,class
> boost::_bi::bind_t<void,class boost::_mfi::mf2<void,class
> sd::framework::ConfigurationControllerResourceManager,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> const &,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XConfiguration> const &>,class
> boost::_bi::list3<class boost::_bi::value<class
> sd::framework::ConfigurationControllerResourceManager *>,class
> boost::arg<1>,class boost::_bi::value<class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XConfiguration> > > >)
> function name:     public: void __thiscall
> sd::framework::ConfigurationControllerResourceManager::DeactivateResources(class
> _STL::vector<class com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId>,class _STL::allocator<class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XResourceId> > > const &,class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XConfiguration> const &)
> function name:     private: void __thiscall
> sd::framework::ConfigurationUpdater::UpdateCore(class
> sd::framework::ConfigurationClassifier const &)
> function name:     private: void __thiscall
> sd::framework::ConfigurationUpdater::UpdateConfiguration(void)
> function name:     public: void __thiscall
> sd::framework::ConfigurationUpdater::RequestUpdate(class
> com::sun::star::uno::Reference<class
> com::sun::star::drawing::framework::XConfiguration> const &)
> function name:     public: void __thiscall
> sd::framework::ChangeRequestQueueProcessor::ProcessOneEvent(void)
> function name:     public: void __thiscall
> sd::framework::ChangeRequestQueueProcessor::ProcessUntilEmpty(void)
> function name:     public: virtual void __cdecl
> cppu::WeakComponentImplHelperBase::dispose(void)
> function name:     private: void __thiscall
> sd::DrawController::DisposeFrameworkControllers(void)
> function name:     public: virtual void __cdecl
> sd::DrawController::dispose(void)
> function name:     public: virtual unsigned char __cdecl
> framework::Frame::setComponent(class com::sun::star::uno::Reference<class
> com::sun::star::awt::XWindow> const &,class
> com::sun::star::uno::Reference<class com::sun::star::frame::XController>
> const &)
> function name:     public: virtual void __cdecl
> framework::Frame::close(unsigned char)
> function name:     public: unsigned char __thiscall SfxFrame::DoClose(void)
> function name:     protected: virtual void __thiscall
> SfxTopViewFrame::Notify(class SfxBroadcaster &,class SfxHint const &)
> function name:     public: void __thiscall SfxBroadcaster::Broadcast(class
> SfxHint const &)
> function name:     public: virtual void __cdecl
> SfxModelListener_Impl::notifyClosing(struct
> com::sun::star::lang::EventObject const &)
> function name:     public: virtual void __cdecl
> SfxBaseModel::close(unsigned char)
> function name:     public: class com::sun::star::uno::XInterface *
> __thiscall bridges::cpp_uno::shared::UnoInterfaceProxy::getCppI(void)
> function name:     public: class com::sun::star::uno::XInterface *
> __thiscall bridges::cpp_uno::shared::UnoInterfaceProxy::getCppI(void)
> function name:     void __cdecl
> bridges::cpp_uno::shared::unoInterfaceProxyDispatch(struct _uno_Interface
> *,struct _typelib_TypeDescription const *,void *,void * * const,struct
> _uno_Any * *)
> function name:     _thisDispatch
> function name:     public: void __thiscall
> bridges_urp::ServerMultiJob::execute(void)
> function name:     void __cdecl _STL::_Construct<struct _STL::pair<class
> rtl::ByteSequence const ,class _STL::list<class bridges_urp::ClientJob
> *,class _STL::allocator<class bridges_urp::ClientJob *> > >,struct
> _STL::pair<class rtl::ByteSequence const ,class _STL::list<class
> bridges_urp::ClientJob *,class _STL::allocator<class bridges_urp::ClientJob
> *> > > >(struct _STL::pair<class rtl::ByteSequence const ,class
> _STL::list<class bridges_urp::ClientJob *,class _STL::allocator<class
> bridges_urp::ClientJob *> > > *,struct _STL::pair<class rtl::ByteSequence
> const ,class _STL::list<class bridges_urp::ClientJob *,class
> _STL::allocator<class bridges_urp::ClientJob *> > > const &)
> function name:     public: void * __thiscall
> cppu_threadpool::JobQueue::enter(__int64,unsigned char)
> function name:     public: void __thiscall
> cppu_threadpool::ORequestThread::run(void)
> function name:     _osl_getGlobalMutex
> Stack frame position [0]
> Stack frame position [0]
> Stack frame position [0]
>
>
>
>
>
>
> On Fri, Dec 4, 2009 at 12:24 AM, Carsten Driesner <
> [email protected]> wrote:
>
>> Huaidong Qiu wrote:
>>
>>> Hi all,
>>>
>>> dtrans\source\win32\dnd\target.cxx
>>>
>>> I encountered a freeze problem recently, the office freezed in function
>>> DropTarget::initialize
>>>
>>> void SAL_CALL DropTarget::initialize( const Sequence< Any >& aArguments )
>>>        throw(Exception, RuntimeException)
>>> {
>>>
>>> ..........
>>>            m_hOleThread= CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)
>>> DndTargetOleSTAFunc,
>>>                                            &m_evtThreadReady, 0,
>>> &m_threadIdTarget);
>>>            WaitForSingleObject( m_evtThreadReady, INFINITE);
>>>
>>> ..........
>>> }
>>>
>>> After several days investigation, I think the maybe the function
>>> WaitForSingleObject is missused.
>>>
>>> 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* function.
>>> Therefore, if you have a thread that creates windows, use
>>> *MsgWaitForMultipleObjects* or *MsgWaitForMultipleObjectsEx*,
>>> 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.
>>>
>>> And this issue also mentioned in this MSDN tech article The Rules of the
>>> Component Object Model, in the section Apartment Threading Model
>>>
>>> http://msdn.microsoft.com/en-us/library/ms810016.aspx
>>>
>>>  Hi Huaidong,
>>
>> I think your findings look convincing. I am not the maintainer of the
>> project and therefore cannot approve your changes. Do you know what thread
>> calls DropTarget::initialize? Is this the main thread (the thread that
>> normally executes the message loop?
>>
>> Regards,
>> Carsten
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>

Reply via email to