DocumentEventListener problem

Stephan Bergmann sbergman at redhat.com
Tue Apr 14 07:04:20 PDT 2015


On 04/13/2015 06:06 PM, Michael Stahl wrote:
> On 12.04.2015 22:53, Piet van Oostrum wrote:
>> I am trying to program a Global DocumentEventListener in Python.
>> Then on a certain event (e.g. File Open), I want to analyse/print the paragraph structure of the document.
>>
>> I am running LibreOffice on port 2002. I am using the internal Python from LibreOffice, but I run the script externally, from a Terminal.
>>
>> This is on Mac OS X 10.10, and LO 4.4.2.2.
>>
>> The listener works and gives output until I start an Enumeration, for example enumerating the paragraphs. After the first element LO hangs completely, and the only way out is to kill it. I have tried also with enumerationg the TextFields in the document and it also hangs.
>>
>> So I am wondering if I do something illegal or unsupported, or that I have hit a bug.
>
> looks like a deadlock, quite easy to reproduce, hope Stephan has some
> time to look at it:

There's nothing special here.  LO's main thread 1 in 
SfxBaseModel::postEvent_Impl (frame 19) is illegally issuing 
css.document.XDocumentEventListener::documentEventOccured calls with the 
solar mutex locked.  The python process, while synchronously executing 
that documentEventOccured call, first issues a bunch of asynchronous 
release requests and then a synchronous 
css.document.XDocumentEventBroadcaster::addDocumentEventListener 
request.  One of the asyncronous release requests, executed on LO's 
thread 2, blocks waiting on the solar mutex.  And on the LO side, the 
incoming synchronous addDocumentEventListener request blocks waiting on 
the preceding asynchronous release requests to finish (which is how 
synchronous and asynchronous UNO requests work).

The bad news is that trying to fix the bad LO thread 1 call stack by 
sticking a SolarMutexReleaser into SfxBaseModel::postEvent_Impl would 
cause lots of new crashes and deadlocks to pop up.  (For example, that 
temporary release of the solar mutex would cause a mismatch in the order 
in which the solar mutex and 
sd::framework::ChangeRequestQueueProcessor::maMutex get locked, causing 
JunitTest_forms_complex to deadlock.)


More information about the LibreOffice mailing list