toolkit/source/awt/vclxwindow.cxx |    1 -
 vcl/source/window/window.cxx      |    1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 97a2f97bf994b9804fa509e06e352ce99b02007b
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Feb 28 12:18:40 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Feb 29 11:13:28 2024 +0100

    tdf#159735 a11y: Dispose win accessible with VCLXWindow
    
    `Window::dispose` takes care of disposing its
    accessible as well.
    
    However, `VCLXWindow::dispose` was explicitly unsetting
    the accessible before disposing its `vcl::Window`, resulting
    in it not getting disposed, in turn resulting in a crash on exit
    for the tdf#159735 case.
    
    Potentially related:
    
        commit 5aa60be574ece81b27c8f63e6e809871c694dba0
        Date:   Wed May 12 11:33:06 2021 +0200
    
            fix leak in VCLXWindow
    
            which is a little tricky because dispose() can be called from either
            side (vcl::Window or VCLXWindow)
    
    Before that commit, setting a nullptr accessible happened
    in the `VCLXWindow` dtor, which is meant to get called after
    the `vcl::Window` got disposed in `VCLXWindow::dispose`.
    (In the Linux bibisect repo, the commit before that one is fine
    and at that commit, the tdf#159735 comment 5 scenario even
    crashes in step 3 already.)
    
    Don't unset the `vcl::Window`'s accessible any more in
    `VCLXWindow::dispose`, but do that after disposing it in
    `vcl::Window::dispose` instead, which seems to be the
    natural place to do that anyway.
    
    Backtrace of crash:
    
        Thread 1 received signal SIGSEGV, Segmentation fault.
        0x00007fd754ae6fe9 in 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>::disposeAndClear
 (this=0x7ffccdc2b5b8, rGuard=..., rEvt=...) at 
include/comphelper/interfacecontainer4.hxx:397
        397                     aIt.next()->disposing(rEvt);
        (gdb) bt
        #0  0x00007fd754ae6fe9 in 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>::disposeAndClear(std::unique_lock<std::mutex>&,
 com::sun::star::lang::EventObject const&)
            (this=0x7ffccdc2b5b8, rGuard=..., rEvt=...) at 
include/comphelper/interfacecontainer4.hxx:397
        #1  0x00007fd754ae6014 in 
comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing(unsigned int, 
com::sun::star::uno::Reference<com::sun::star::uno::XInterface> const&)
            (_nClient=28, _rxEventSource=uno::Reference to 
(accessibility::AccessibleListBox *) 0x55bf49c0ad00) at 
.../libreoffice/comphelper/source/misc/accessibleeventnotifier.cxx:204
        #2  0x00007fd754ae1424 in 
comphelper::OCommonAccessibleComponent::disposing() (this=0x55bf49c0ad00) at 
.../libreoffice/comphelper/source/misc/accessiblecomponenthelper.cxx:61
        #3  0x00007fd74e884512 in VCLXAccessibleComponent::disposing() 
(this=0x55bf49c0ad00) at 
.../libreoffice/toolkit/source/awt/vclxaccessiblecomponent.cxx:376
        #4  0x00007fd6a3d506b7 in accessibility::AccessibleListBox::disposing() 
(this=0x55bf49c0ad00) at 
.../libreoffice/accessibility/source/extended/accessiblelistbox.cxx:246
        #5  0x00007fd75453f544 in cppu::WeakComponentImplHelperBase::dispose() 
(this=0x55bf49c0ad00) at .../libreoffice/cppuhelper/source/implbase.cxx:104
        #6  0x00007fd6a3d45fd5 in 
cppu::PartialWeakComponentImplHelper<com::sun::star::accessibility::XAccessibleContext2,
 com::sun::star::accessibility::XAccessibleEventBroadcaster>::dispose() 
(this=0x55bf49c0ad00)
            at include/cppuhelper/compbase.hxx:90
        #7  0x00007fd75453f1fe in cppu::WeakComponentImplHelperBase::release() 
(this=0x55bf49c0ad00) at .../libreoffice/cppuhelper/source/implbase.cxx:79
        #8  0x00007fd6a3d47d85 in 
cppu::PartialWeakComponentImplHelper<com::sun::star::accessibility::XAccessibleContext2,
 com::sun::star::accessibility::XAccessibleEventBroadcaster>::release() 
(this=0x55bf49c0ad00)
            at include/cppuhelper/compbase.hxx:86
        #9  0x00007fd6a3d47ca5 in 
cppu::ImplInheritanceHelper<comphelper::OCommonAccessibleComponent, 
com::sun::star::accessibility::XAccessibleExtendedComponent>::release() 
(this=0x55bf49c0ad00) at include/cppuhelper/implbase.hxx:171
        #10 0x00007fd6a3d47c85 in 
cppu::ImplInheritanceHelper<comphelper::OAccessibleExtendedComponentHelper, 
com::sun::star::lang::XServiceInfo>::release() (this=0x55bf49c0ad00) at 
include/cppuhelper/implbase.hxx:171
        #11 0x00007fd6a3d45f55 in 
cppu::ImplInheritanceHelper<VCLXAccessibleComponent, 
com::sun::star::accessibility::XAccessible, 
com::sun::star::accessibility::XAccessibleSelection>::release() 
(this=0x55bf49c0ad00)
            at include/cppuhelper/implbase.hxx:171
        #12 0x00007fd74282e13e in 
com::sun::star::uno::Reference<com::sun::star::uno::XInterface>::~Reference() 
(this=0x55bf49c0e860) at include/com/sun/star/uno/Reference.hxx:114
        #13 0x00007fd7428524c5 in 
std::destroy_at<com::sun::star::uno::Reference<com::sun::star::uno::XInterface> 
>(com::sun::star::uno::Reference<com::sun::star::uno::XInterface>*) 
(__location=0x55bf49c0e860)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:88
        #14 0x00007fd7428524a5 in 
std::_Destroy<com::sun::star::uno::Reference<com::sun::star::uno::XInterface> 
>(com::sun::star::uno::Reference<com::sun::star::uno::XInterface>*) 
(__pointer=0x55bf49c0e860)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:149
        #15 0x00007fd742852477 in 
std::_Destroy_aux<false>::__destroy<com::sun::star::uno::Reference<com::sun::star::uno::XInterface>*>(com::sun::star::uno::Reference<com::sun::star::uno::XInterface>*,
 com::sun::star::uno::Reference<com::sun::star::uno::XInterface>*) 
(__first=0x55bf49c0e860, __last=0x55bf49c0e868) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:163
        #16 0x00007fd74285243d in 
std::_Destroy<com::sun::star::uno::Reference<com::sun::star::uno::XInterface>*>(com::sun::star::uno::Reference<com::sun::star::uno::XInterface>*,
 com::sun::star::uno::Reference<com::sun::star::uno::XInterface>*) 
(__first=0x55bf49c0e860, __last=0x55bf49c0e868) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:195
        #17 0x00007fd742852379 in 
std::_Destroy<com::sun::star::uno::Reference<com::sun::star::uno::XInterface>*, 
com::sun::star::uno::Reference<com::sun::star::uno::XInterface> 
>(com::sun::star::uno::Reference<com::sun::star::uno::XInterface>*, 
com::sun::star::uno::Reference<com::sun::star::uno::XInterface>*, 
std::allocator<com::sun::star::uno::Reference<com::sun::star::uno::XInterface> 
>&) (__first=0x55bf49c0e860, __last=0x55bf49c0e868)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/alloc_traits.h:948
        #18 
std::__cxx1998::vector<com::sun::star::uno::Reference<com::sun::star::uno::XInterface>,
 std::allocator<com::sun::star::uno::Reference<com::sun::star::uno::XInterface> 
> >::~vector() (this=0x55bf4d1120f8)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_vector.h:732
        #19 0x00007fd74285231d in 
std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::uno::XInterface>,
 std::allocator<com::sun::star::uno::Reference<com::sun::star::uno::XInterface> 
> >::~vector() (this=0x55bf4d1120e0)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/debug/vector:230
        #20 0x00007fd7428522f5 in 
o3tl::sorted_vector<com::sun::star::uno::Reference<com::sun::star::uno::XInterface>,
 std::less<com::sun::star::uno::Reference<com::sun::star::uno::XInterface> >, 
o3tl::find_unique>::~sorted_vector()
            (this=0x55bf4d1120e0) at include/o3tl/sorted_vector.hxx:47
        #21 0x00007fd74284f83d in 
DocumentFocusListener::~DocumentFocusListener() (this=0x55bf4d1120b0) at 
vcl/inc/unx/gtk/gtkdata.hxx:221
        #22 0x00007fd74284f869 in 
DocumentFocusListener::~DocumentFocusListener() (this=0x55bf4d1120b0) at 
vcl/inc/unx/gtk/gtkdata.hxx:221
        #23 0x00007fd7546453a0 in cppu::OWeakObject::release() 
(this=0x55bf4d1120b0) at .../libreoffice/cppuhelper/source/weak.cxx:230
        #24 0x00007fd742834415 in 
cppu::WeakImplHelper<com::sun::star::accessibility::XAccessibleEventListener>::release()
 (this=0x55bf4d1120b0) at include/cppuhelper/implbase.hxx:115
        #25 0x00007fd754aec91e in 
com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>::~Reference()
 (this=0x55bf4896c088) at include/com/sun/star/uno/Reference.hxx:114
        #26 0x00007fd754aec8e5 in 
std::destroy_at<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>
 
>(com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>*)
            (__location=0x55bf4896c088) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:88
        #27 0x00007fd754aec8c5 in 
std::_Destroy<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>
 
>(com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>*)
            (__pointer=0x55bf4896c088) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:149
        #28 0x00007fd754aec897 in 
std::_Destroy_aux<false>::__destroy<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>*>(com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>*,
 
com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>*)
 (__first=0x55bf4896c088, __last=0x55bf4896c090)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:163
        #29 0x00007fd754aec85d in 
std::_Destroy<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>*>(com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>*,
 
com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>*)
 (__first=0x55bf4896c080, __last=0x55bf4896c090) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:195
        #30 0x00007fd754aec799 in 
std::_Destroy<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>*,
 
com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>
 
>(com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>*,
 
com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>*,
 
std::allocator<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>
 >&) (__first=0x55bf4896c080, __last=0x55bf4896c090) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/alloc_traits.h:948
        --Type <RET> for more, q to quit, c to continue without paging--
        #31 
std::__cxx1998::vector<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>,
 
std::allocator<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>
 > >::~vector()
            (this=0x55bf49866bc8) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_vector.h:732
        #32 0x00007fd754aec73d in 
std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>,
 
std::allocator<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>
 > >::~vector() (this=0x55bf49866bb0) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/debug/vector:230
        #33 0x00007fd754aec715 in 
o3tl::cow_wrapper<std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>,
 
std::allocator<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>
 > >, o3tl::ThreadSafeRefCountingPolicy>::impl_t::~impl_t() 
(this=0x55bf49866bb0) at include/o3tl/cow_wrapper.hxx:176
        #34 0x00007fd754aec6e4 in 
o3tl::cow_wrapper<std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>,
 
std::allocator<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>
 > >, o3tl::ThreadSafeRefCountingPolicy>::release() (this=0x55bf49b28380) at 
include/o3tl/cow_wrapper.hxx:207
        #35 0x00007fd754aec675 in 
o3tl::cow_wrapper<std::__debug::vector<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>,
 
std::allocator<com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessibleEventListener>
 > >, o3tl::ThreadSafeRefCountingPolicy>::~cow_wrapper() (this=0x55bf49b28380) 
at include/o3tl/cow_wrapper.hxx:271
        #36 0x00007fd754ae6ae5 in 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>::~OInterfaceContainerHelper4()
 (this=0x55bf49b28380) at include/comphelper/interfacecontainer4.hxx:126
        #37 0x00007fd754ae7c49 in std::pair<unsigned int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 >::~pair() (this=0x55bf49b28378)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_pair.h:187
        #38 0x00007fd754ae7c25 in std::destroy_at<std::pair<unsigned int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 > >(std::pair<unsigned int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 >*) (__location=0x55bf49b28378) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_construct.h:88
        #39 0x00007fd754ae7b4b in 
std::allocator_traits<std::allocator<std::__detail::_Hash_node<std::pair<unsigned
 int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 >, false> > >::destroy<std::pair<unsigned int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 > >(std::allocator<std::__detail::_Hash_node<std::pair<unsigned int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 >, false> >&, std::pair<unsigned int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 >*)
            (__a=..., __p=0x55bf49b28378) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/alloc_traits.h:560
        #40 
std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<unsigned
 int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 >, false> > >::_M_deallocate_node(std::__detail::_Hash_node<std::pair<unsigned 
int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 >, false>*)
            (this=0x7fd754d2aaa8 <(anonymous namespace)::gaClients+40>, 
__n=0x55bf49b28370) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/hashtable_policy.h:2011
        #41 0x00007fd754ae7ab5 in 
std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<unsigned
 int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 >, false> > 
>::_M_deallocate_nodes(std::__detail::_Hash_node<std::pair<unsigned int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 >, false>*)
            (this=0x7fd754d2aaa8 <(anonymous namespace)::gaClients+40>, 
__n=0x0) at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/hashtable_policy.h:2033
        #42 0x00007fd754ae79df in std::_Hashtable<unsigned int, 
std::pair<unsigned int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 >, std::allocator<std::pair<unsigned int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 > >, std::__detail::_Select1st, std::equal_to<unsigned int>, 
std::hash<unsigned int>, std::__detail::_Mod_range_hashing, 
std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, 
std::__detail::_Hashtable_traits<false, false, true> >::clear() 
(this=0x7fd754d2aaa8 <(anonymous namespace)::gaClients+40>)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/hashtable.h:2524
        #43 0x00007fd754af6415 in std::__cxx1998::unordered_map<unsigned int, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>,
 std::hash<unsigned int>, std::equal_to<unsigned int>, 
std::allocator<std::pair<unsigned int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 > > >::clear() (this=0x7fd754d2aaa8 <(anonymous namespace)::gaClients+40>)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/unordered_map.h:798
        #44 0x00007fd754ae778d in std::__debug::unordered_map<unsigned int, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>,
 std::hash<unsigned int>, std::equal_to<unsigned int>, 
std::allocator<std::pair<unsigned int const, 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>
 > > >::clear() (this=0x7fd754d2aa80 <(anonymous namespace)::gaClients>)
            at 
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/debug/unordered_map:234
        #45 0x00007fd754ae6640 in 
comphelper::AccessibleEventNotifier::shutdown() () at 
.../libreoffice/comphelper/source/misc/accessibleeventnotifier.cxx:268
        #46 0x00007fd74d3c5e41 in DeInitVCL() () at 
.../libreoffice/vcl/source/app/svmain.cxx:619
        #47 0x00007fd74d3c4031 in ImplSVMain() () at 
.../libreoffice/vcl/source/app/svmain.cxx:254
        #48 0x00007fd74d3c5f79 in SVMain() () at 
.../libreoffice/vcl/source/app/svmain.cxx:261
        #49 0x00007fd7565a4ba3 in soffice_main() () at 
.../libreoffice/desktop/source/app/sofficemain.cxx:94
        #50 0x000055bf472e7a5d in sal_main () at 
.../libreoffice/desktop/source/app/main.c:51
        #51 0x000055bf472e7a37 in main (argc=3, argv=0x7ffccdc2c9a8) at 
.../libreoffice/desktop/source/app/main.c:49
    
    Change-Id: I251b2f97184e0492f02eb772e5906847f9249506
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164090
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    (cherry picked from commit 2ea7cdf9876ce2de61458982247ab6861e1aac2f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164113
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/toolkit/source/awt/vclxwindow.cxx 
b/toolkit/source/awt/vclxwindow.cxx
index 930d8fe4eaee..2a4957e7bda9 100644
--- a/toolkit/source/awt/vclxwindow.cxx
+++ b/toolkit/source/awt/vclxwindow.cxx
@@ -921,7 +921,6 @@ void VCLXWindow::dispose(  )
     {
         pWindow->RemoveEventListener( LINK( this, VCLXWindow, 
WindowEventListener ) );
         pWindow->SetWindowPeer( nullptr, nullptr );
-        pWindow->SetAccessible( nullptr );
 
         SetOutputDevice( nullptr );
         pWindow.disposeAndClear();
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index f79918fd7f52..9d74b57b3bdb 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -223,6 +223,7 @@ void Window::dispose()
         Reference< XComponent> xC( mpWindowImpl->mxAccessible, UNO_QUERY );
         if ( xC.is() )
             xC->dispose();
+        mpWindowImpl->mxAccessible.clear();
     }
 
     ImplSVData* pSVData = ImplGetSVData();

Reply via email to