Apache OpenOffice (AOO) Bugzilla – Issue 109939
toolkit: inconsistent UnoControl locking schemes
Last modified: 2013-01-29 21:43:40 UTC
UnoControl::getAccessibleContext first locks the SolarMutex and then its own mutex (DEV300_m74 toolkit/source/controls/unocontrol.cxx l. 1484--1485), while UnoControl::draw locks its own mutex (l. 1039 before calling ImplGetCompatiblePeer (l. 1041), which in turn potentially locks the SolarMutex (l. 223). This inconsistency can potentially lead to deadlocks. @fs: According to cd, there is probably no good reason for UnoControl to have its own mutex at all, instead of always using the SolarMutex (unless you know of any good reasons). (I stumbled over this when executing forms/qa/unoapi on DEV300_m74-based CWS sb118 unxlngi6 non-pro once caused OOo to hang with the attached stack traces, of which especially the second, interesting one is unfortunately completely garbled for unknown reasons. The tail of the output generated by the forms/qa/unoapi test, executed by a "subsequenttests -P4" invocation, is: ---8<--- 6: Method getFastPropertyValue() finished with state OK 6: LOG> getFastPropertyValue(): PASSED.OK 6: ***** State for forms.OFileControlModel::com::sun::star::beans::XFastPropertySet ****** 6: Whole interface: PASSED.OK 6: *************************************************************************************** 6: LOG> Log started 08.02.2010 - 14:50:02 6: checking: [forms.OFileControlModel::com::sun::star::beans::XPropertyState] is iface: [com.sun.star.beans.XPropertyState] testcode: [ifc.beans._XPropertyState] 6: LOG> Property 'Align' has attributes 67 6: LOG> Execute: getPropertyState() 6: Method getPropertyState() finished with state OK 6: LOG> getPropertyState(): PASSED.OK 6: 6: LOG> Execute: getPropertyStates() 6: Method getPropertyStates() finished with state OK 6: LOG> getPropertyStates(): PASSED.OK 6: 6: LOG> Execute: setPropertyToDefault() 6: LOG> starting required method: getPropertyDefault() 6: LOG> Execute: getPropertyDefault() 6: LOG> Default property value is : '0' 6: Method getPropertyDefault() finished with state OK 6: LOG> getPropertyDefault(): PASSED.OK 6: 6: LOG> Default value = '0', returned value = '0' for property Align 6: Method setPropertyToDefault() finished with state OK 6: LOG> setPropertyToDefault(): PASSED.OK 6: LOG> disposing xDrawDoc 6: ***** State for forms.OFileControlModel::com::sun::star::beans::XPropertOG> Get: ? ---8<--- Whether or not that deadlock is related to this issue is unclear due to the garbled stacks, however.)
Created attachment 68219 [details] stack traces
@sb: All the listener containers/multiplexers (see UnoControl's maFooListeners members) use the osl-mutex, as they're based on ::cppu::OInterfaceContainerHelper. So, at least this containers assumes that the osl mutex is used for thread safety. So, I assume replacing the osl mutex usage with solar mutex usage would technically work, but potentially lead to other, perhaps more subtle problems. Also, I don't really like the idea of paving UnoControl and derivees with SolarMutex locks. SolarMutex usage is kind of transitive, so it would propagate itself to e.g. form controls immediately. At some point, this renders multi-threading useless. In the current situation, where the SM is used only where needed (and in UnoControl::draw, it obviously is strictly needed), we have a few deadlocks now and then (rarely nowadays, really), but don't infest everything with the SM pest. A state which I'd prefer.
see issue 111006 for another UnoControl locking problem
Now also observed when executing forms/qa/unoapi on DEV300_m77-based CWS sb120 under unxsoli4 non-pro, deadlocks while "checking: [forms.OFileControlModel::com::sun::star::awt::UnoControlFileControlModel] is iface: [com.sun.star.beans.XPropertySet] testcode: [ifc.awt._UnoControlFileControlModel]" (see below for stacks). Worked around for now by disabling the affected tests in forms/qa/unoapi/forms.sce, see <http://hg.services.openoffice.org/cws/sb120/rev/cdf052ee8916>; please revert when fixing this issue. (dbx) threads > t@1 a l@1 ?() sleep on 0x919ffd8 in __lwp_park() t@2 a l@2 rtl_cache_wsupdate_all() sleep on 0xfee715f0 in __lwp_park() t@3 a l@3 osl_thread_start_Impl() running in _so_accept() t@4 a l@4 osl_thread_start_Impl() running in _so_accept() t@5 a l@5 osl_thread_start_Impl() sleep on 0x8065eb8 in __lwp_park() t@10 a l@10 osl_thread_start_Impl() sleep on 0x8bb1020 in __lwp_park() t@11 a l@11 osl_thread_start_Impl() running in _so_recv() t@69 a l@69 osl_thread_start_Impl() sleep on 0x91a02d8 in __lwp_park() t@70 a l@70 osl_thread_start_Impl() sleep on 0x8065eb8 in __lwp_park() (dbx) thread -blockedby t@1 Thread t@1 is blocked by: 0x0919ffd8 (0x919ffd8): usync_? mutex(locked) Lock owned by t@69 (dbx) thread -blockedby t@69 Thread t@69 is blocked by: 0x091a02d8 (0x91a02d8): usync_? mutex(locked) Lock owned by t@1 (dbx) where t@1 current thread: t@1 dbx: warning: Too many #included source files near __dflt_argW -- limit is 1023 dbx: warning: Too many #included source files near __dflt_argV -- limit is 1023 [1] __lwp_park(0x0, 0x0), at 0xfef749ab [2] mutex_lock_queue(0xfefb2000, 0x0, 0x919ffd8, 0x0), at 0xfef6d937 [3] slow_lock(0xfefb2000, 0x919ffd8, 0x0), at 0xfef6e224 [4] mutex_lock_impl(0x919ffd8, 0x0), at 0xfef6e31a [5] __mutex_lock(0x919ffd8, 0xfe7266dc, 0x80436a8, 0xfecabaa2), at 0xfef6e426 =>[6] osl_acquireMutex(Mutex = ???) (optimized), at 0xfecababd (line ~129) in "mutex.c" [7] UnoControl::propertiesChange(this = ???, rEvents = CLASS) (optimized), at 0xfd486ec3 (line ~443) in "unocontrol.cxx" [8] cppu::OPropertySetHelper::firePropertiesChangeEvent(this = ???, rPropertyNames = CLASS, rListener = CLASS) (optimized), at 0xfe6a17c4 (line ~931) in "propshlp.cxx" [9] UnoControl::updateFromModel(this = ???) (optimized), at 0xfd4866f5 (line ~356) in "unocontrol.cxx" [10] UnoControl::createPeer(this = ???, rxToolkit = CLASS, rParentPeer = CLASS) (optimized), at 0xfd48d40d (line ~1338) in "unocontrol.cxx" [11] UnoEditControl::createPeer(this = ???, rxToolkit = CLASS, rParentPeer = CLASS) (optimized), at 0xfd4aa048 (line ~249) in "unocontrols.cxx" [12] UnoControlContainer::impl_createControlPeerIfNecessary(this = ???, _rxControl = CLASS) (optimized), at 0xfd497372 (line ~648) in "unocontrolcontainer.cxx" [13] UnoControlContainer::impl_addControl(this = ???, _rxControl = CLASS, _pName = ???) (optimized), at 0xfd497486 (line ~661) in "unocontrolcontainer.cxx" [14] UnoControlContainer::addControl(this = ???, rName = CLASS, rControl = CLASS) (optimized), at 0xfd497746 (line ~678) in "unocontrolcontainer.cxx" [15] sdr::contact::ViewObjectContactOfUnoControl_Impl::createControlForDevice(_rPageView = CLASS, _rDevice = CLASS, _rUnoObject = CLASS, _rInitialViewTransformation = STRUCT, _rInitialZoomNormalization = STRUCT, _out_rControl = CLASS) (optimized), at 0xf20cab0f (line ~1249) in "viewobjectcontactofunocontrol.cxx" [16] sdr::contact::ViewObjectContactOfUnoControl_Impl::impl_ensureControl_nothrow(this = ???, _rPageView = CLASS, _rDevice = CLASS, _rInitialViewTransformation = STRUCT) (optimized), at 0xf20c9c82 (line ~1173) in "viewobjectcontactofunocontrol.cxx" [17] sdr::contact::ViewObjectContactOfUnoControl_Impl::ensureControl(this = ???, _pInitialViewTransformationOrNULL = ???) (optimized), at 0xf20c9792 (line ~1073) in "viewobjectcontactofunocontrol.cxx" [18] sdr::contact::LazyControlCreationPrimitive2D::create2DDecomposition(this = ???, _rViewInformation = STRUCT) (optimized), at 0xf20cef4c (line ~1681) in "viewobjectcontactofunocontrol.cxx" [19] drawinglayer::primitive2d::BufferedDecompositionPrimitive2D::get2DDecomposition(this = ???, rViewInformation = CLASS) (optimized), at 0xf0cc3e41 (line ~106) in "baseprimitive2d.cxx" [20] sdr::contact::LazyControlCreationPrimitive2D::get2DDecomposition(this = ???, _rViewInformation = STRUCT) (optimized), at 0xf20cee9d (line ~1666) in "viewobjectcontactofunocontrol.cxx" [21] drawinglayer::processor2d::VclPixelProcessor2D::processBasePrimitive2D(this = ???, rCandidate = CLASS) (optimized), at 0xf0d50682 (line ~577) in "vclpixelprocessor2d.cxx" [22] drawinglayer::processor2d::BaseProcessor2D::process(this = ???, rSource = CLASS) (optimized), at 0xf0d3edff (line ~75) in "baseprocessor2d.cxx" [23] sdr::contact::ObjectContactOfPageView::DoProcessDisplay(this = ???, rDisplayInfo = CLASS) (optimized), at 0xf20f4c25 (line ~268) in "objectcontactofpageview.cxx" [24] sdr::contact::ObjectContactOfPageView::ProcessDisplay(this = ???, rDisplayInfo = CLASS) (optimized), at 0xf20f422c (line ~133) in "objectcontactofpageview.cxx" [25] SdrPageWindow::RedrawAll(this = ???, pRedirector = ???) (optimized), at 0xf24f84ae (line ~335) in "sdrpagewindow.cxx" [26] SdrPageView::CompleteRedraw(this = ???, rPaintWindow = CLASS, rReg = CLASS, pRedirector = ???) (optimized), at 0xf2439fdd (line ~377) in "svdpagv.cxx" [27] SdrPaintView::DoCompleteRedraw(this = ???, rPaintWindow = CLASS, rReg = CLASS, pRedirector = ???) (optimized), at 0xf244fa38 (line ~888) in "svdpntv.cxx" [28] SdrPaintView::CompleteRedraw(this = ???, pOut = ???, rReg = CLASS, pRedirector = ???) (optimized), at 0xf244f8c6 (line ~801) in "svdpntv.cxx" [29] sd::View::CompleteRedraw(this = ???, pOutDev = ???, rReg = CLASS, pRedirector = ???) (optimized), at 0xed87755c (line ~542) in "sdview.cxx" [30] sd::DrawView::CompleteRedraw(this = ???, pOutDev = ???, rReg = CLASS, pRedirector = ???) (optimized), at 0xed8ef5e8 (line ~520) in "drawview.cxx" [31] sd::DrawViewShell::Paint(this = ???, rRect = CLASS, pWin = ???) (optimized), at 0xed8b6dbf (line ~484) in "drviews5.cxx" [32] sd::Window::Paint(this = ???, rRect = CLASS) (optimized), at 0xed8a001e (line ~310) in "sdwindow.cxx" [33] Window::ImplCallPaint(this = ???, pRegion = ???, nPaintFlags = ???) (optimized), at 0xfce05e38 (line ~2434) in "window.cxx" [34] Window::ImplCallPaint(this = ???, pRegion = ???, nPaintFlags = ???) (optimized), at 0xfce05f01 (line ~2458) in "window.cxx" [35] Window::ImplCallPaint(this = ???, pRegion = ???, nPaintFlags = ???) (optimized), at 0xfce05f01 (line ~2458) in "window.cxx" [36] Window::ImplCallPaint(this = ???, pRegion = ???, nPaintFlags = ???) (optimized), at 0xfce05f01 (line ~2458) in "window.cxx" [37] Window::ImplCallPaint(this = ???, pRegion = ???, nPaintFlags = ???) (optimized), at 0xfce05f01 (line ~2458) in "window.cxx" [38] Window::ImplCallPaint(this = ???, pRegion = ???, nPaintFlags = ???) (optimized), at 0xfce05f01 (line ~2458) in "window.cxx" [39] Window::ImplCallPaint(this = ???, pRegion = ???, nPaintFlags = ???) (optimized), at 0xfce05f01 (line ~2458) in "window.cxx" [40] Window::ImplCallPaint(this = ???, pRegion = ???, nPaintFlags = ???) (optimized), at 0xfce05f01 (line ~2458) in "window.cxx" [41] Window::ImplCallOverlapPaint(this = ???) (optimized), at 0xfce06093 (line ~2495) in "window.cxx" [42] Window::ImplHandlePaintHdl(this = ???, _ARG2 = ???) (optimized), at 0xfce0613e (line ~2515) in "window.cxx" [43] Window::LinkStubImplHandlePaintHdl(pThis = ???, pCaller = ???) (optimized), at 0xfce060f5 (line ~2509) in "window.cxx" [44] Window::ImplHandleResizeTimerHdl(this = ???, _ARG2 = ???) (optimized), at 0xfce061e8 (line ~2529) in "window.cxx" [45] Window::LinkStubImplHandleResizeTimerHdl(pThis = ???, pCaller = ???) (optimized), at 0xfce06179 (line ~2521) in "window.cxx" [46] Window::GetSizePixel(this = ???) (optimized), at 0xfce14782 (line ~6662) in "window.cxx" [47] DockingWindow::GetSizePixel(this = ???) (optimized), at 0xfcd8944e (line ~1026) in "dockwin.cxx" [48] SfxWorkWindow::Arrange_Impl(this = ???) (optimized), at 0xf6dc22bb (line ~899) in "workwin.cxx" [49] SfxFrameWorkWin_Impl::ArrangeChilds_Impl(this = ???, bForce = ???) (optimized), at 0xf6dc20e4 (line ~835) in "workwin.cxx" [50] SfxWorkWindow::Lock_Impl(this = ???, bLock = ???) (optimized), at 0xf6dc193d (line ~672) in "workwin.cxx" [51] LayoutManagerListener::layoutEvent(this = ???, _ARG2 = STRUCT, eLayoutEvent = ???, _ARG4 = CLASS) (optimized), at 0xf6dc02f8 (line ~323) in "workwin.cxx" [52] framework::LayoutManager::implts_notifyListeners(this = ???, nEvent = ???, aInfoParam = CLASS) (optimized), at 0xf59449e2 (line ~6912) in "layoutmanager.cxx" [53] framework::LayoutManager::unlock(this = ???) (optimized), at 0xf593be37 (line ~5449) in "layoutmanager.cxx" [54] SfxDispatcher::Update_Impl(this = ???, bForce = ???) (optimized), at 0xf6f6fd8f (line ~1779) in "dispatch.cxx" [55] DispatcherUpdate_Impl(_ARG1 = ???, pArg = ???) (optimized), at 0xf6f85f00 (line ~1252) in "shell.cxx" [56] svtools::AsynchronLink::Call_Impl(this = ???, pArg = ???) (optimized), at 0xfdc7a293 (line ~131) in "asynclink.cxx" [57] svtools::AsynchronLink::HandleCall(pThis = ???, _ARG2 = ???) (optimized), at 0xfdc7a1a0 (line ~104) in "asynclink.cxx" [58] ImplHandleUserEvent(pSVEvent = ???) (optimized), at 0xfce27d66 (line ~1997) in "winproc.cxx" [59] ImplWindowFrameProc(pWindow = ???, _ARG2 = ???, nEvent = ???, pEvent = ???) (optimized), at 0xfce285da (line ~2569) in "winproc.cxx" [60] SalDisplay::DispatchInternalEvent(this = ???) (optimized), at 0xf8f9d1da (line ~2246) in "saldisp.cxx" [61] GtkXLib::userEventFn(data = ???) (optimized), at 0xfb85fd3a (line ~767) in "gtkdata.cxx" [62] call_userEventFn(data = ???) (optimized), at 0xfb85fc56 (line ~740) in "gtkdata.cxx" [63] g_idle_dispatch(0xfb5ef5b0, 0x2, 0x8084c90, 0xffffff9c, 0x23, 0xd2d1), at 0xfb594b4d (dbx) where t@69 current thread: t@69 =>[1] __lwp_park(0x0, 0x0), at 0xfef749ab [2] mutex_lock_queue(0xfb0a1400, 0x0, 0x91a02d8, 0x0), at 0xfef6d937 [3] slow_lock(0xfb0a1400, 0x91a02d8, 0x0), at 0xfef6e224 [4] mutex_lock_impl(0x91a02d8, 0x0), at 0xfef6e31a [5] __mutex_lock(0x91a02d8, 0xef178e10, 0xfd6cb9f8, 0xfecabaa2), at 0xfef6e426 [6] osl_acquireMutex(Mutex = ???) (optimized), at 0xfecababd (line ~129) in "mutex.c" [7] UnoControl::getPeer(this = ???) (optimized), at 0xfd48d7e7 (line ~1361) in "unocontrol.cxx" [8] UnoControl::getParentPeer(this = ???) (optimized), at 0xfd486497 (line ~339) in "unocontrol.cxx" [9] UnoControl::ImplModelPropertiesChanged(this = ???, rEvents = STRUCT) (optimized), at 0xfd487d4d (line ~610) in "unocontrol.cxx" [10] UnoControl::propertiesChange(this = ???, rEvents = STRUCT) (optimized), at 0xfd4870a1 (line ~466) in "unocontrol.cxx" [11] cppu::OPropertySetHelper::fire(this = ???, pnHandles = ???, pNewValues = ???, pOldValues = ???, nHandles = ???, bVetoable = ???) (optimized), at 0xfe6a06f0 (line ~712) in "propshlp.cxx" [12] comphelper::OPropertySetAggregationHelper::propertiesChange(this = ???, _rEvents = CLASS) (optimized), at 0xfe09156a (line ~506) in "propagg.cxx" [13] cppu::OPropertySetHelper::fire(this = ???, pnHandles = ???, pNewValues = ???, pOldValues = ???, nHandles = ???, bVetoable = ???) (optimized), at 0xfe6a06f0 (line ~712) in "propshlp.cxx" [14] cppu::OPropertySetHelper::setFastPropertyValues(this = ???, nSeqLen = ???, pHandles = ???, pValues = ???, nHitCount = ???) (optimized), at 0xfe6a0edf (line ~806) in "propshlp.cxx" [15] UnoControlModel::setFastPropertyValue(this = ???, nPropId = ???, rValue = CLASS) (optimized), at 0xfd4a6177 (line ~1383) in "unocontrolmodel.cxx" [16] comphelper::OPropertySetAggregationHelper::setFastPropertyValue(this = ???, _nHandle = ???, _rValue = CLASS) (optimized), at 0xfe092281 (line ~648) in "propagg.cxx" [17] cppu::OPropertySetHelper::setPropertyValue(this = ???, rPropertyName = CLASS, rValue = CLASS) (optimized), at 0xfe69ec98 (line ~256) in "propshlp.cxx" [18] callVirtualMethod(0xecf93b98, 0x4, 0x0, 0x0, 0xefb9d570, 0x4, 0x8089e80, 0x8bb18cc), at 0xf89d8971 [19] __unnamed_KARQ_TcB0LmV6::cpp_call(pThis = ???, aVtableSlot = STRUCT, pReturnTypeRef = ???, nParams = ???, pParams = ???, pUnoReturn = ???, pUnoArgs = ???, ppUnoExc = ???) (optimized), at 0xf89d480e (line ~207) in "uno2cpp.cxx" [20] bridges::cpp_uno::shared::unoInterfaceProxyDispatch(pUnoI = ???, pMemberDescr = ???, pReturn = ???, pArgs = ???, ppException = ???) (optimized), at 0xf89d3f04 (line ~396) in "uno2cpp.cxx" [21] thisDispatch(pRemoteI = 0x8ec6700, pType = 0x8093a20, pReturn = (nil), ppArgs = 0xecde4a04, ppException = 0xecde49c4), line 173 in "stub.cxx" [22] bridges_urp::ServerMultiJob::execute(this = ???) (optimized), at 0xef8ef2df (line ~677) in "urp_job.cxx" [23] doit(job = ???) (optimized), at 0xef8ece7e (line ~69) in "urp_job.cxx" [24] cppu_threadpool::JobQueue::enter(this = ???, nDisposeId = ???, bReturnWhenNoJob = ???) (optimized), at 0xf8cb8d73 (line ~117) in "jobqueue.cxx" [25] cppu_threadpool::ORequestThread::run(this = ???) (optimized), at 0xf8cb987d (line ~193) in "thread.cxx" [26] cppu_requestThreadWorker(pVoid = ???) (optimized), at 0xf8cb924e (line ~46) in "thread.cxx" [27] osl_thread_start_Impl(pData = ???) (optimized), at 0xfecac747 (line ~266) in "thread.c" [28] _thr_setup(0xfb0a1400), at 0xfef74662 [29] _lwp_start(0x0, 0x0, 0x0, 0xfb0a1400, 0x91a02d8, 0xfef9e000), at 0xfef74950
Disabled further tests causing similar deadlocks in forms/qa/unoapi/forms.sce, see <http://hg.services.openoffice.org/cws/sb120/rev/ecae6ff6c784>; please revert when fixing this issue.