summaryrefslogtreecommitdiff
path: root/stoc
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-06-29 09:54:16 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-06-29 11:53:47 +0200
commit4cc1b2b55bf4efd21530632eccd9c01267a71218 (patch)
tree470b46004977772b921db33e3b2db2508caa1750 /stoc
parentf52fe2eb855d1233bacb97baf192a3c07fc1822e (diff)
Missing acquire in UNO constructor function
...that was lost in 951a9342631129832e647bd8a303a959308bad65 "use single-use attribute for JavaVirtualMachine". (Noticed with `SDK_HOME=.../instdir/sdk URE_HOME=.../instdir make -f Makefile.pln test-javatest` in ure/source/uretest failing at [...] > warn:legacy.osl:1255514:1255514:cppuhelper/source/implbase.cxx:84: OSL_ASSERT: rBHelper.bDisposed > ================================================================= > ==1255514==ERROR: AddressSanitizer: heap-use-after-free on address 0x610000001740 at pc 0x7f14cbe32a2a bp 0x7fff46636a70 sp 0x7fff46636a68 > READ of size 8 at 0x610000001740 thread T0 > #0 in com::sun::star::uno::cpp_release(void*) at include/com/sun/star/uno/genfunc.hxx:52:43 > #1 in cppu::_release(void*, void (*)(void*)) at cppu/source/uno/prim.hxx:85:13 > #2 in cppu::_destructAny(_uno_Any*, void (*)(void*)) at cppu/source/uno/destr.hxx:129:9 > #3 in uno_any_destruct at cppu/source/uno/any.cxx:131:5 > #4 in com::sun::star::uno::Any::~Any() at include/com/sun/star/uno/Any.hxx:115:5 > #5 in cppu::(anonymous namespace)::ComponentContext::ContextEntry::~ContextEntry() at cppuhelper/source/component_context.cxx:131:12 > #6 in std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>::~pair() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/stl_iterator.h:2368:12 > #7 in void std::destroy_at<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry> >(std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/stl_construct.h:88:15 > #8 in void std::allocator_traits<std::allocator<std::__detail::_Hash_node<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, true> > >::destroy<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry> >(std::allocator<std::__detail::_Hash_node<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, true> >&, std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/alloc_traits.h:533:4 > #9 in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, true> > >::_M_deallocate_node(std::__detail::_Hash_node<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, true>*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/hashtable_policy.h:1932:7 > #10 in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, true> > >::_M_deallocate_nodes(std::__detail::_Hash_node<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, true>*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/hashtable_policy.h:1954:4 > #11 in std::_Hashtable<rtl::OUString, std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, std::allocator<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry> >, std::__detail::_Select1st, std::equal_to<rtl::OUString>, std::hash<rtl::OUString>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::clear() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/hashtable.h:2332:13 > #12 in std::__cxx1998::unordered_map<rtl::OUString, cppu::(anonymous namespace)::ComponentContext::ContextEntry, std::hash<rtl::OUString>, std::equal_to<rtl::OUString>, std::allocator<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry> > >::clear() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/unordered_map.h:791:14 > #13 in std::__debug::unordered_map<rtl::OUString, cppu::(anonymous namespace)::ComponentContext::ContextEntry, std::hash<rtl::OUString>, std::equal_to<rtl::OUString>, std::allocator<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry> > >::clear() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/debug/unordered_map:223:9 > #14 in cppu::(anonymous namespace)::ComponentContext::disposing() at cppuhelper/source/component_context.cxx:444:11 > #15 in cppu::WeakComponentImplHelperBase::dispose() at cppuhelper/source/implbase.cxx:104:13 > #16 in cppu::PartialWeakComponentImplHelper<com::sun::star::uno::XComponentContext, com::sun::star::container::XNameContainer>::dispose() at include/cppuhelper/compbase.hxx:90:36 > #17 in sal_main() at cpputools/source/unoexe/unoexe.cxx:540:16 > #18 in main at cpputools/source/unoexe/unoexe.cxx:358:1 > > 0x610000001740 is located 0 bytes inside of 192-byte region [0x610000001740,0x610000001800) > freed by thread T0 here: > #0 in free at ~/github.com/llvm/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:111:3 > #1 in rtl_freeMemory at sal/rtl/alloc_global.cxx:51:5 > #2 in cppu::WeakComponentImplHelperBase::operator delete(void*) at include/cppuhelper/compbase_ex.hxx:70:11 > #3 in stoc_javavm::JavaVirtualMachine::~JavaVirtualMachine() at stoc/source/javavm/javavm.cxx:1122:1 > #4 in cppu::OWeakObject::release() at cppuhelper/source/weak.cxx:242:9 > #5 in cppu::WeakComponentImplHelperBase::release() at cppuhelper/source/implbase.cxx:86:18 > #6 in cppu::PartialWeakComponentImplHelper<com::sun::star::lang::XInitialization, com::sun::star::lang::XServiceInfo, com::sun::star::java::XJavaVM, com::sun::star::java::XJavaThreadRegister_11, com::sun::star::container::XContainerListener>::release() at include/cppuhelper/compbase.hxx:86:36 > #7 in com::sun::star::uno::Reference<com::sun::star::uno::XInterface>::~Reference() at include/com/sun/star/uno/Reference.hxx:114:22 > #8 in cppuhelper::ServiceManager::Data::Implementation::~Implementation() at cppuhelper/source/servicemanager.hxx:72:16 > #9 in void std::destroy_at<cppuhelper::ServiceManager::Data::Implementation>(cppuhelper::ServiceManager::Data::Implementation*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/stl_construct.h:88:15 > #10 in void std::allocator_traits<std::allocator<cppuhelper::ServiceManager::Data::Implementation> >::destroy<cppuhelper::ServiceManager::Data::Implementation>(std::allocator<cppuhelper::ServiceManager::Data::Implementation>&, cppuhelper::ServiceManager::Data::Implementation*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/alloc_traits.h:533:4 > #11 in std::_Sp_counted_ptr_inplace<cppuhelper::ServiceManager::Data::Implementation, std::allocator<cppuhelper::ServiceManager::Data::Implementation>, (__gnu_cxx::_Lock_policy)2>::_M_dispose() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:528:2 > #12 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:168:6 > #13 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:705:11 > #14 in std::__shared_ptr<cppuhelper::ServiceManager::Data::Implementation, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr_base.h:1154:31 > #15 in std::shared_ptr<cppuhelper::ServiceManager::Data::Implementation>::~shared_ptr() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/shared_ptr.h:122:11 > #16 in (anonymous namespace)::SingletonFactory::~SingletonFactory() at cppuhelper/source/servicemanager.cxx:510:43 > #17 in (anonymous namespace)::SingletonFactory::~SingletonFactory() at cppuhelper/source/servicemanager.cxx:510:42 > #18 in cppu::OWeakObject::release() at cppuhelper/source/weak.cxx:242:9 > #19 in cppu::WeakImplHelper<com::sun::star::lang::XSingleComponentFactory>::release() at include/cppuhelper/implbase.hxx:115:66 > #20 in com::sun::star::uno::cpp_release(void*) at include/com/sun/star/uno/genfunc.hxx:52:43 > #21 in cppu::_release(void*, void (*)(void*)) at cppu/source/uno/prim.hxx:85:13 > #22 in cppu::_destructAny(_uno_Any*, void (*)(void*)) at cppu/source/uno/destr.hxx:129:9 > #23 in uno_any_destruct at cppu/source/uno/any.cxx:131:5 > #24 in com::sun::star::uno::Any::~Any() at include/com/sun/star/uno/Any.hxx:115:5 > #25 in cppu::(anonymous namespace)::ComponentContext::ContextEntry::~ContextEntry() at cppuhelper/source/component_context.cxx:131:12 > #26 in std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>::~pair() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/stl_iterator.h:2368:12 > #27 in void std::destroy_at<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry> >(std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/stl_construct.h:88:15 > #28 in void std::allocator_traits<std::allocator<std::__detail::_Hash_node<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, true> > >::destroy<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry> >(std::allocator<std::__detail::_Hash_node<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, true> >&, std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/alloc_traits.h:533:4 > #29 in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, true> > >::_M_deallocate_node(std::__detail::_Hash_node<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, true>*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/hashtable_policy.h:1932:7 > #30 in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, true> > >::_M_deallocate_nodes(std::__detail::_Hash_node<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, true>*) at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/hashtable_policy.h:1954:4 > #31 in std::_Hashtable<rtl::OUString, std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry>, std::allocator<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry> >, std::__detail::_Select1st, std::equal_to<rtl::OUString>, std::hash<rtl::OUString>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::clear() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/hashtable.h:2332:13 > #32 in std::__cxx1998::unordered_map<rtl::OUString, cppu::(anonymous namespace)::ComponentContext::ContextEntry, std::hash<rtl::OUString>, std::equal_to<rtl::OUString>, std::allocator<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry> > >::clear() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/unordered_map.h:791:14 > #33 in std::__debug::unordered_map<rtl::OUString, cppu::(anonymous namespace)::ComponentContext::ContextEntry, std::hash<rtl::OUString>, std::equal_to<rtl::OUString>, std::allocator<std::pair<rtl::OUString const, cppu::(anonymous namespace)::ComponentContext::ContextEntry> > >::clear() at ~/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../include/c++/12.0.0/debug/unordered_map:223:9 > #34 in cppu::(anonymous namespace)::ComponentContext::disposing() at cppuhelper/source/component_context.cxx:444:11 > #35 in cppu::WeakComponentImplHelperBase::dispose() at cppuhelper/source/implbase.cxx:104:13 > #36 in cppu::PartialWeakComponentImplHelper<com::sun::star::uno::XComponentContext, com::sun::star::container::XNameContainer>::dispose() at include/cppuhelper/compbase.hxx:90:36 > #37 in sal_main() at cpputools/source/unoexe/unoexe.cxx:540:16 > #38 in main at cpputools/source/unoexe/unoexe.cxx:358:1 when presumably removing first /singletons/com.sun.star.java.theJavaVirtualMachine/service and then /singletons/com.sun.star.java.theJavaVirtualMachine from ComponentContext::m_map.) Change-Id: If1563e463becb4d22b754e173ebcb60386e1d828 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118049 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'stoc')
-rw-r--r--stoc/source/javavm/javavm.cxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx
index a2ed761ef35a..47a735464040 100644
--- a/stoc/source/javavm/javavm.cxx
+++ b/stoc/source/javavm/javavm.cxx
@@ -50,6 +50,7 @@
#include <comphelper/SetFlagContextHelper.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <cppuhelper/weak.hxx>
#include <jvmaccess/classpath.hxx>
#include <jvmaccess/unovirtualmachine.hxx>
#include <jvmaccess/virtualmachine.hxx>
@@ -1477,7 +1478,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
stoc_JavaVM_get_implementation(
css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
{
- return static_cast<cppu::OWeakObject*>(new JavaVirtualMachine(context));
+ return cppu::acquire(new JavaVirtualMachine(context));
}