vcl/source/app/svmain.cxx |   28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
New commits:
commit a9f55e37e5ac6e282250fcfbe7a7f18b2596e574
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Sat Oct 19 21:31:06 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Sun Oct 20 07:59:48 2024 +0200

    Fix CppunitTest_sw_a11y crash: clear mxAccessBridge in DeInitVCL
    
    I see the crash locally on Windows 11, in a 64-bit build. Debugging it,
    I see this call stack:
    
      
vcllo.dll!std::unique_ptr<comphelper::SolarMutex,std::default_delete<comphelper::SolarMutex>>::get()
 Line 3433
      vcllo.dll!SalInstance::GetYieldMutex() Line 142
      vcllo.dll!Application::GetSolarMutex() Line 492
      tklo.dll!SolarMutexGuard::SolarMutexGuard() Line 1340
      tklo.dll!VCLXDevice::~VCLXDevice() Line 45
      
tklo.dll!cppu::ImplInheritanceHelper<VCLXDevice,com::sun::star::awt::XWindow2,com::sun::star::awt::XVclWindowPeer,com::sun::star::awt::XLayoutConstrains,com::sun::star::awt::XView,com::sun::star::awt::XDockableWindow,com::sun::star::accessibility::XAccessible,com::sun::star::lang::XEventListener,com::sun::star::beans::XPropertySetInfo,com::sun::star::awt::XStyleSettingsSupplier>::~ImplInheritanceHelper<VCLXDevice,com::sun::star::awt::XWindow2,com::sun::star::awt::XVclWindowPeer,com::sun::star::awt::XLayoutConstrains,com::sun::star::awt::XView,com::sun::star::awt::XDockableWindow,com::sun::star::accessibility::XAccessible,com::sun::star::lang::XEventListener,com::sun::star::beans::XPropertySetInfo,com::sun::star::awt::XStyleSettingsSupplier>()
 Line 155
      tklo.dll!VCLXWindow::~VCLXWindow() Line 336
      
tklo.dll!cppu::ImplInheritanceHelper<VCLXWindow,com::sun::star::awt::XVclContainer,com::sun::star::awt::XVclContainerPeer>::~ImplInheritanceHelper<VCLXWindow,com::sun::star::awt::XVclContainer,com::sun::star::awt::XVclContainerPeer>()
 Line 155
      tklo.dll!VCLXContainer::~VCLXContainer() Line 42
      
tklo.dll!cppu::ImplInheritanceHelper<VCLXContainer,com::sun::star::awt::XTopWindow3,com::sun::star::awt::XSystemDependentWindowPeer>::~ImplInheritanceHelper<VCLXContainer,com::sun::star::awt::XTopWindow3,com::sun::star::awt::XSystemDependentWindowPeer>()
 Line 155
      tklo.dll!VCLXTopWindow::~VCLXTopWindow() Line 240
      tklo.dll!VCLXTopWindow::`scalar deleting destructor'(unsigned int)
      cppuhelper3MSC.dll!cppu::OWeakObject::release() Line 230
      
tklo.dll!cppu::WeakImplHelper<com::sun::star::awt::XDevice,com::sun::star::awt::XUnitConversion>::release()
 Line 115
      
tklo.dll!cppu::ImplInheritanceHelper<VCLXDevice,com::sun::star::awt::XWindow2,com::sun::star::awt::XVclWindowPeer,com::sun::star::awt::XLayoutConstrains,com::sun::star::awt::XView,com::sun::star::awt::XDockableWindow,com::sun::star::accessibility::XAccessible,com::sun::star::lang::XEventListener,com::sun::star::beans::XPropertySetInfo,com::sun::star::awt::XStyleSettingsSupplier>::release()
 Line 171
      
tklo.dll!cppu::ImplInheritanceHelper<VCLXWindow,com::sun::star::awt::XVclContainer,com::sun::star::awt::XVclContainerPeer>::release()
 Line 171
      
tklo.dll!cppu::ImplInheritanceHelper<VCLXContainer,com::sun::star::awt::XTopWindow3,com::sun::star::awt::XSystemDependentWindowPeer>::release()
 Line 171
      
winaccessibility.dll!com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>::set(com::sun::star::accessibility::XAccessible
 * pInterface) Line 247
      
winaccessibility.dll!com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>::operator=(com::sun::star::accessibility::XAccessible
 * pInterface) Line 351
      winaccessibility.dll!AccObject::~AccObject() Line 283
      winaccessibility.dll!std::pair<com::sun::star::accessibility::XAccessible 
* const,AccObject>::~pair<com::sun::star::accessibility::XAccessible * 
const,AccObject>()
      winaccessibility.dll!std::pair<com::sun::star::accessibility::XAccessible 
* const,AccObject>::`scalar deleting destructor'(unsigned int)
      
winaccessibility.dll!std::destroy_at<std::pair<com::sun::star::accessibility::XAccessible
 * const,AccObject>>(std::pair<com::sun::star::accessibility::XAccessible * 
const,AccObject> * const _Location) Line 306
      
winaccessibility.dll!std::_Default_allocator_traits<std::allocator<std::_Tree_node<std::pair<com::sun::star::accessibility::XAccessible
 * const,AccObject>,void 
*>>>::destroy<std::pair<com::sun::star::accessibility::XAccessible * 
const,AccObject>>(std::allocator<std::_Tree_node<std::pair<com::sun::star::accessibility::XAccessible
 * const,AccObject>,void *>> & __formal, 
std::pair<com::sun::star::accessibility::XAccessible * const,AccObject> * const 
_Ptr) Line 707
      
winaccessibility.dll!std::_Tree_node<std::pair<com::sun::star::accessibility::XAccessible
 * const,AccObject>,void 
*>::_Freenode<std::allocator<std::_Tree_node<std::pair<com::sun::star::accessibility::XAccessible
 * const,AccObject>,void 
*>>>(std::allocator<std::_Tree_node<std::pair<com::sun::star::accessibility::XAccessible
 * const,AccObject>,void *>> & _Al, 
std::_Tree_node<std::pair<com::sun::star::accessibility::XAccessible * 
const,AccObject>,void *> * _Ptr) Line 382
      
winaccessibility.dll!std::_Tree_val<std::_Tree_simple_types<std::pair<com::sun::star::accessibility::XAccessible
 * 
const,AccObject>>>::_Erase_tree<std::allocator<std::_Tree_node<std::pair<com::sun::star::accessibility::XAccessible
 * const,AccObject>,void 
*>>>(std::allocator<std::_Tree_node<std::pair<com::sun::star::accessibility::XAccessible
 * const,AccObject>,void *>> & _Al, 
std::_Tree_node<std::pair<com::sun::star::accessibility::XAccessible * 
const,AccObject>,void *> * _Rootnode) Line 760
      
winaccessibility.dll!std::_Tree<std::_Tmap_traits<com::sun::star::accessibility::XAccessible
 *,AccObject,std::less<com::sun::star::accessibility::XAccessible 
*>,std::allocator<std::pair<com::sun::star::accessibility::XAccessible * 
const,AccObject>>,0>>::clear() Line 1365
      winaccessibility.dll!AccObjectWinManager::~AccObjectWinManager() Line 67
      winaccessibility.dll!AccTopWindowListener::~AccTopWindowListener() Line 
100
      winaccessibility.dll!AccTopWindowListener::`scalar deleting 
destructor'(unsigned int)
      cppuhelper3MSC.dll!cppu::OWeakObject::release() Line 230
      
winaccessibility.dll!cppu::WeakImplHelper<com::sun::star::awt::XTopWindowListener>::release()
 Line 115
      
winaccessibility.dll!rtl::Reference<AccTopWindowListener>::~Reference<AccTopWindowListener>()
 Line 126
      winaccessibility.dll!my_sc_impl::`anonymous 
namespace'::MSAAServiceImpl::~MSAAServiceImpl()
      winaccessibility.dll!my_sc_impl::`anonymous 
namespace'::MSAAServiceImpl::`scalar deleting destructor'(unsigned int)
      cppuhelper3MSC.dll!cppu::OWeakObject::release() Line 230
      
winaccessibility.dll!cppu::WeakImplHelper<com::sun::star::accessibility::XMSAAService,com::sun::star::lang::XServiceInfo>::release()
 Line 115
      
vcllo.dll!com::sun::star::uno::Reference<com::sun::star::lang::XComponent>::~Reference<com::sun::star::lang::XComponent>()
 Line 114
      vcllo.dll!ImplSVData::~ImplSVData() Line 509
      vcllo.dll!`rtl::Static<ImplSVData,`anonymous 
namespace'::private_aImplSVData>::get'::`2'::`dynamic atexit destructor for 
'instance''()
      ucrtbased.dll!_execute_onexit_table::__l2::<lambda>() Line 206
      ucrtbased.dll!__crt_seh_guarded_call<int>::operator()<void 
<lambda>(void),int <lambda>(void) &,void 
<lambda>(void)>(__acrt_lock_and_call::__l2::void <lambda>(void) && setup, 
_execute_onexit_table::__l2::int <lambda>(void) & action, 
__acrt_lock_and_call::__l2::void <lambda>(void) && cleanup) Line 204
      ucrtbased.dll!__acrt_lock_and_call<int <lambda>(void)>(const 
__acrt_lock_id lock_id, _execute_onexit_table::__l2::int <lambda>(void) && 
action) Line 974
      ucrtbased.dll!_execute_onexit_table(_onexit_table_t * table) Line 231
      vcllo.dll!__scrt_dllmain_uninitialize_c() Line 398
      vcllo.dll!dllmain_crt_process_detach(const bool is_terminating) Line 182
      vcllo.dll!dllmain_crt_dispatch(HINSTANCE__ * const instance, const 
unsigned long reason, void * const reserved) Line 220
      vcllo.dll!dllmain_dispatch(HINSTANCE__ * const instance, const unsigned 
long reason, void * const reserved) Line 293
      vcllo.dll!_DllMainCRTStartup(HINSTANCE__ * const instance, const unsigned 
long reason, void * const reserved) Line 335
      ntdll.dll!LdrpCallInitRoutine()
      ntdll.dll!LdrShutdownProcess()
      ntdll.dll!RtlExitUserProcess()
      kernel32.dll!ExitProcessImplementation()
      ucrtbased.dll!exit_or_terminate_process(const unsigned int return_code) 
Line 138
      ucrtbased.dll!common_exit(const int return_code, const 
_crt_exit_cleanup_mode cleanup_mode, const _crt_exit_return_mode return_mode) 
Line 274
      ucrtbased.dll!exit(int return_code) Line 288
      cppunittester.exe!__scrt_common_main_seh() Line 295
      cppunittester.exe!__scrt_common_main() Line 331
      cppunittester.exe!mainCRTStartup(void * __formal) Line 17
      kernel32.dll!BaseThreadInitThunk()
      ntdll.dll!RtlUserThreadStart()
    
    where in Application::GetSolarMutex, pSVData->mpDefInst is nullptr,
    so in the end, the message is:
    
      Exception thrown: read access violation.
      this was 0x10.
    
    This change moves the hack introduced in commit
    05d2a415654e2b9324f70d92871df20ca964dc43 (INTEGRATION: CWS vcl37
    (1.52.38); FILE MERGED, 2005-03-29), which obviously solved the same
    problem. The CppUnit case is different, because there ImplSVMain is
    not used, but instead, DeInitVCL is called from Protector dtor
    (test/source/vclbootstrapprotector.cxx). So doing it in the start of
    DeInitVCL looks a reasonable solution to me.
    
    Change-Id: I5ba740a6b94bbdabc28538dbbcf8cd211bb56f16
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175198
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 2da2344daf97..47df58d33965 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -235,20 +235,6 @@ int ImplSVMain()
         pSVData->mxDisplayConnection.clear();
     }
 
-    // This is a hack to work around the problem of the asynchronous nature
-    // of bridging accessibility through Java: on shutdown there might still
-    // be some events in the AWT EventQueue, which need the SolarMutex which
-    // - on the other hand - is destroyed in DeInitVCL(). So empty the queue
-    // here ..
-    if( pSVData->mxAccessBridge.is() )
-    {
-        {
-            SolarMutexReleaser aReleaser;
-            pSVData->mxAccessBridge->dispose();
-        }
-        pSVData->mxAccessBridge.clear();
-    }
-
     WatchdogThread::stop();
     DeInitVCL();
 
@@ -460,6 +446,20 @@ void DeInitVCL()
     }
     ImplSVData* pSVData = ImplGetSVData();
 
+    // This is a hack to work around the problem of the asynchronous nature
+    // of bridging accessibility through Java: on shutdown there might still
+    // be some events in the AWT EventQueue, which need the SolarMutex which
+    // - on the other hand - is destroyed in DeInitVCL(). So empty the queue
+    // here ..
+    if (pSVData->mxAccessBridge.is())
+    {
+        {
+            SolarMutexReleaser aReleaser;
+            pSVData->mxAccessBridge->dispose();
+        }
+        pSVData->mxAccessBridge.clear();
+    }
+
     // lp#1560328: clear cache before disposing rest of VCL
     if(pSVData->mpBlendFrameCache)
         pSVData->mpBlendFrameCache->m_aLastResult.Clear();

Reply via email to