embeddedobj win32: avoid owning a lock while calling out to event listeners

Desktop / LibreOffice - Miklos Vajna [collabora.co.uk] - 7 November 2018 16:32 EST

The deadlock happens from time to time, when converting documents containing OLE objects via remote UNO (from Java) -- after the conversion, when closing the document.

The relevant stacktraces are:

>Debug.ListCallStack /ShowLineOffset /AllThreads Callstack for Thread 8 (Thread Id: 32912 (0x8090)):

6 sal3.dll!osl_acquireMutex(_oslMutexImpl * Mutex) Line 75 7 [Inline Frame] emboleobj.dll!osl::Mutex::acquire() Line 56 8 [Inline Frame] emboleobj.dll!osl::Guard::{ctor}(osl::Mutex &) Line 129 9 emboleobj.dll!OleComponent::OnClose_Impl() Line 1399 10 emboleobj.dll!OleWrapperAdviseSink::OnClose() Line 119

Callstack for Thread 11 (Thread Id: 21088 (0x5260)):

11 ole32.dll!00007fffc5e44e83() 12 [Inline Frame] emboleobj.dll!OleComponent::CloseObject() Line 1012 13 emboleobj.dll!OleComponent::Dispose() Line 484 14 emboleobj.dll!OleComponent::close(unsigned char bDeliverOwnership) Line 1463 15 emboleobj.dll!OleEmbeddedObject::GetRidOfComponent() Line 239 16 emboleobj.dll!OleEmbeddedObject::Dispose() Line 275 17 emboleobj.dll!OleEmbeddedObject::close(unsigned char bDeliverOwnership) Line 497

26 swlo.dll!SwXTextDocument::close(unsigned char bDeliverOwnership) Line 617

OleComponent::OnClose_Impl() taking a lock is fine, but OleComponent::close() takes a lock and then later it still calls out (via OleComponent::CloseObject()), which is a no-go.

Fix the problem by making sure that callers of Dispose() own no lock at the time of the function call, and taking the lock in Dispose() only after the CloseObject() call (which invokes event listeners).

Change-Id: I53befee21478188c7f79723b7d7596e66077d1c2 Reviewed-on: https://gerrit.libreoffice.org/63014

fe83001574b4 embeddedobj win32: avoid owning a lock while calling out to event listeners
embeddedobj/source/msole/olecomponent.cxx | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

Upstream: cgit.freedesktop.org

  • Share