Bug 53008 - SolarMutex deadlock when closing Calc which contains functions with XVolatileResult return values
Summary: SolarMutex deadlock when closing Calc which contains functions with XVolatile...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Spreadsheet (show other bugs)
Version: 3.5.0 Beta2
Hardware: Other All
: medium normal
Assignee: Not Assigned
QA Contact:
URL:
Whiteboard: BSA
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-31 15:09 UTC by Wendi Chen
Modified: 2013-11-18 16:52 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
The analyzed result of a full dump file (28.18 KB, text/plain)
2012-07-31 15:09 UTC, Wendi Chen
Details

Description Wendi Chen 2012-07-31 15:09:11 UTC
Created attachment 64997 [details]
The analyzed result of a full dump file

Problem description: 

Recently, I am working on developing a Calc extension for showing dynamic streaming data, such as Bloomberg and Reuters real time data. The extension is written in C++ for Windows OS and contains add-in functions for retrieving dynamic financial data. Based on the OpenOffice/LibreOffice developer's guide, the function returns XVolatileResult derived data type.

There are two threads. The main thread deals with spreadsheet, such as calling functions. The second thread gets the streaming messages, processes them and notify spreadsheet (the main thread) data changes via Reference<XResultListener> -> modified(EventResult) function within XVolatileResult derived object.

The deadlock scenario is that the spreadsheet called the functions many times and was showing dynamical financial data. Then I closed the spreadsheet window. The window quit immediately, but the soffice.bin and soffice.exe were still in task manager. I had to kill these processes manually. From the log file, I saw that main thread hung at destruction process, trying to close the second thread, and the second thread hang at Reference<XResultLisenter> -> modified(), trying to update the spreadsheet. 

After doing some research, I suspect that the deadlock is because of SolarMutex. The main thread starts termination process, acquires SolarMutex, and tries to close the second thread. But the second thread can not complete if the Listener->modified() function is waiting for SolarMutex too.

This is a multi-threads issue. I saw a similar bug report at http://nabble.documentfoundation.org/Base-hangs-when-trying-to-close-it-td3798832.html

A patch tried to solve the above bug: https://bugs.freedesktop.org/attachment.cgi?id=58176. However, this patch is reverted from release version LibreOffice 3.6.0 : http://wiki.documentfoundation.org/Releases/3.6.0/RC2 
(do#47021 revert "attempt fix of hang on base close, due to solarmutex deadlock on join" [Michael Stahl]) .

I am wondering if there is a signal which I can detect when the termination process starts. If yes, then I can prepare for the termination in the extension. Or if I can release the Solarmutex in my code to let thread 2 complete the modified() function? Any other suggestions?

I attached the analyzed result of a full dump file which is created manually by Explorer Process (no crash with the processes hanging). If you'd like to check out the mini/full dump files, or need more information, please feel free to let me know. thanks.

Wendi

Steps to reproduce:
1. ....
2. ....
3. ....

Current behavior:

Expected behavior:

Platform (if different from the browser): Windows XP
       
Browser: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0
Comment 2 Joel Madero 2013-06-28 01:16:56 UTC
> I am wondering if there is a signal which I can detect when the termination
> process starts. If yes, then I can prepare for the termination in the
> extension. Or if I can release the Solarmutex in my code to let thread 2
> complete the modified() function? Any other suggestions?
> 

This comment makes me think it's not a bug report but instead a request for help but to confirm this - requesting input from developers
Comment 3 Eike Rathke 2013-06-28 14:34:08 UTC
It is actually a bug report because the implementation for XVolatileResult listeners/broadcasters has some quirks. AFAIR I asked Wendi to report that as a bug so it doesn't get lost. Alas, I didn't have time to dive into.
Comment 4 Robinson Tryon (qubit) 2013-10-19 00:58:53 UTC
Removing comma from whiteboard (please use a space to delimit values in this field)
https://wiki.documentfoundation.org/QA/Bugzilla/Fields/Whiteboard#Getting_Started
Comment 5 Robinson Tryon (qubit) 2013-11-18 16:52:52 UTC
Bug is confirmed and NEW
Whiteboard: Removing 'Need_Advice'


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.