Apache OpenOffice (AOO) Bugzilla – Issue 105557
[sw] unocore: no destructor locking
Last modified: 2017-05-20 11:15:52 UTC
locking of UNO implementation in writer is completely broken in one aspect: destructors the destructors of UNO objects are invoked from remote bridges when the remote side no longer references the UNO object. currently, most UNO objects in writer do not do any locking. worse, simply putting in a SolarMutex guard does not help: the guard will be dropped before destructors of base classes and members are invoked. possible solutions: 1. make all potential base classes threadsafe 2. prohibit non-threadsafe base classes, and introduce pImpl objects that then derive from the non-threadsafe base classes. the UNO object destructor locks SolarMutex and explicitly deletes pImpl (auto_ptr does not work!) 3. wait for the mythical threading framework to solve all our locking problems...
.
a related problem: various uno objects are "cached": they register as SwClient at a core object, and there is code to iterate over the registered clients at the core object, find the uno object, and construct a uno reference from the pointer. carefully reviewing the design with mhu revealed that it is broken: - thread A calls OWeakObject::release on a SwXBookmark - thread A blocks on solar mutex (that is now in the SwXBookmark dtor) - thread B, which has the solar mutex, iterates over the clients of a core bookmark, and creates a uno reference to the object - thread B releases solar mutex - thread A acquires solar mutex and deletes the SwXBookmark; now the uno reference points to deleted object (after locking the solar mutex in the destructor of SwXBookmark, the complex test "CheckBookmarks" still crashed on solaris due to this problem) the best solution seems to be to put a weak reference to the uno object into the core object (in addition to the entry in the listener list). the weak reference is notified immediately and invalidated when the reference count reaches 0.
partially fixed in CWS swunolocking1: fixed the destructor locking and the SwClient caching problems for: SwXDocumentIndexMark SwXDocumentIndex SwXFootnote SwXHeadFootText SwXBodyText SwXText SwXTextCursor SwXParaFrameEnumeration SwXTextRange SwXTextRanges SwXTextSection SwXParagraphEnumeration SwXParagraph SwXBookmark SwXReferenceMark SwXMeta now CheckBookmarks runs reliably on unxsoli4.
Reset assigne to the default "issues@openoffice.apache.org".