Solarmutex Deadlock when Closing Calc which contains functions with XVolatileResult return values
Stephan Bergmann
sbergman at redhat.com
Thu Aug 9 02:06:01 PDT 2012
On 08/08/2012 08:34 PM, anwen wrote:
> With the TerminateListener, I successfully get the desktop termination event
> by queryTermination() function. Although you told me that I could veto this
> termination signal by throwing TerminationVetoException. I am not sure how
> and where to handle the TerminationVetoException and re-call
> XDesktop.terminate() to finally close the office. So I tried to handle
> everything inside queryTermination().
I think you should execute your shutdown activies on notifyTermination,
not queryTermination. The latter can be veto'ed by some other listener,
in which case Desktop would cancel the termination and continue running
(and notify you with queryTermination eventually followed by
notifyTermination again later on).
> However, deadlock happened sometimes again. Here is my analysis: this
> function is called by the main thread and is protected by the SolarMutex. If
> a modified() function is called by the worker thread at the same time, the
> worker thread is waiting for the SolarMutex. Then the main thread tries to
> stop the worker thread by calling realtime_session->stop(). This session is
> designed with thread safe strategy by a third-party. It fails to close the
> worker thread because the worker thread is waiting for the Main thread to
> release the SolarMutex.
That queryTermination is called with SolarMutex locked is a bug. (Is
notifyTermination also called with SolarMutex locked? Would need to
check, in framework/source/services/desktop.cxx.) However, it might be
a bug not easy to fix without opening any number of pandora's boxes...
Stephan
More information about the LibreOffice
mailing list