[Libreoffice-commits] core.git: basic/inc basic/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Sat Dec 21 07:13:58 UTC 2019
basic/inc/sbxbase.hxx | 4 ++++
basic/source/classes/errobject.cxx | 12 ++++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
New commits:
commit 3ebf6a090b227c0097ff8668fe023e7bdbdadc5d
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Fri Dec 20 12:49:04 2019 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sat Dec 21 08:12:38 2019 +0100
Avoid crash in shutdown when accessing already destroyed BASIC_DLL
... as seen in https://ci.libreoffice.org/job/gerrit_linux_gcc_release/48425/console
The problem was that SbxErrObject::getErrObject created a static object
which called GetSbxData_Impl() in its destructor, which in turn accessed
BASIC_DLL, which was invalidated by deleting BasicDLL objects either in
SfxApplication::~SfxApplication or in MacroSnippet::~MacroSnippet, thus
already invalid when static was destroyed.
So fix this by creating the global error object in the SbxAppData, not
as function-local static, so that its lifetime is limited to the data.
The crash happened also on Windows, but was somehow masked (possibly by
custom error handler?), with this call stack:
sblo.dll!std::unique_ptr<SbxAppData,std::default_delete<SbxAppData>>::operator*() Line 1886
at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\memory(1886)
sblo.dll!GetSbxData_Impl() Line 110
at C:\lo\src\core\basic\source\runtime\basrdll.cxx(110)
sblo.dll!SbxBase::GetError() Line 96
at C:\lo\src\core\basic\source\sbx\sbxbase.cxx(96)
sblo.dll!SbxValue::Put(const SbxValues & rVal) Line 414
at C:\lo\src\core\basic\source\sbx\sbxvalue.cxx(414)
sblo.dll!SbxValue::Clear() Line 179
at C:\lo\src\core\basic\source\sbx\sbxvalue.cxx(179)
sblo.dll!SbxValue::~SbxValue() Line 139
at C:\lo\src\core\basic\source\sbx\sbxvalue.cxx(139)
sblo.dll!SbxVariable::~SbxVariable() Line 125
at C:\lo\src\core\basic\source\sbx\sbxvar.cxx(125)
sblo.dll!SbxProperty::~SbxProperty() Line 861
at C:\lo\src\core\basic\source\sbx\sbxobj.cxx(861)
sblo.dll!SbUnoProperty::~SbUnoProperty() Line 2591
at C:\lo\src\core\basic\source\classes\sbunoobj.cxx(2591)
sblo.dll!SbUnoProperty::`vbase destructor'()
sblo.dll!SbUnoProperty::`scalar deleting destructor'(unsigned int)
tllo.dll!SvRefBase::ReleaseRef() Line 163
at C:\lo\src\core\include\tools\ref.hxx(163)
sblo.dll!tools::SvRef<SbxVariable>::~SvRef<SbxVariable>() Line 56
at C:\lo\src\core\include\tools\ref.hxx(56)
sblo.dll!SbxVarEntry::~SbxVarEntry()
sblo.dll!SbxVarEntry::`scalar deleting destructor'(unsigned int)
sblo.dll!std::_Default_allocator_traits<std::allocator<SbxVarEntry>>::destroy<SbxVarEntry>(std::allocator<SbxVarEntry> & __formal, SbxVarEntry * const _Ptr) Line 677
at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\xmemory(677)
sblo.dll!std::_Destroy_range<std::allocator<SbxVarEntry>>(SbxVarEntry * _First, SbxVarEntry * const _Last, std::allocator<SbxVarEntry> & _Al) Line 951
at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\xmemory(951)
sblo.dll!std::vector<SbxVarEntry,std::allocator<SbxVarEntry>>::_Destroy(SbxVarEntry * _First, SbxVarEntry * _Last) Line 1616
at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\vector(1616)
sblo.dll!std::vector<SbxVarEntry,std::allocator<SbxVarEntry>>::_Tidy() Line 1698
at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\vector(1698)
sblo.dll!std::vector<SbxVarEntry,std::allocator<SbxVarEntry>>::~vector<SbxVarEntry,std::allocator<SbxVarEntry>>() Line 674
at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\include\vector(674)
sblo.dll!SbxArray::~SbxArray() Line 75
at C:\lo\src\core\basic\source\sbx\sbxarray.cxx(75)
sblo.dll!SbxArray::`vbase destructor'()
sblo.dll!SbxArray::`vector deleting destructor'(unsigned int)
tllo.dll!SvRefBase::ReleaseRef() Line 163
at C:\lo\src\core\include\tools\ref.hxx(163)
sblo.dll!tools::SvRef<SbxArray>::~SvRef<SbxArray>() Line 56
at C:\lo\src\core\include\tools\ref.hxx(56)
sblo.dll!SbxObject::~SbxObject() Line 111
at C:\lo\src\core\basic\source\sbx\sbxobj.cxx(111)
sblo.dll!SbUnoObject::~SbUnoObject() Line 2387
at C:\lo\src\core\basic\source\classes\sbunoobj.cxx(2387)
sblo.dll!SbxErrObject::~SbxErrObject() Line 183
at C:\lo\src\core\basic\source\classes\errobject.cxx(183)
sblo.dll!SbxErrObject::`vbase destructor'()
sblo.dll!SbxErrObject::`scalar deleting destructor'(unsigned int)
tllo.dll!SvRefBase::ReleaseRef() Line 163
at C:\lo\src\core\include\tools\ref.hxx(163)
sblo.dll!tools::SvRef<SbxVariable>::~SvRef<SbxVariable>() Line 56
at C:\lo\src\core\include\tools\ref.hxx(56)
sblo.dll!`SbxErrObject::getErrObject'::`2'::`dynamic atexit destructor for 'pGlobErr''()
ucrtbased.dll!_execute_onexit_table::__l2::<lambda>() Line 206
at minkernel\crts\ucrt\src\appcrt\startup\onexit.cpp(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
at vccrt\vcruntime\inc\internal_shared.h(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 975
at minkernel\crts\ucrt\inc\corecrt_internal.h(975)
ucrtbased.dll!_execute_onexit_table(_onexit_table_t * table) Line 231
at minkernel\crts\ucrt\src\appcrt\startup\onexit.cpp(231)
sblo.dll!__scrt_dllmain_uninitialize_c() Line 399
at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\utility\utility.cpp(399)
sblo.dll!dllmain_crt_process_detach(const bool is_terminating) Line 182
at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp(182)
sblo.dll!dllmain_crt_dispatch(HINSTANCE__ * const instance, const unsigned long reason, void * const reserved) Line 220
at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp(220)
sblo.dll!dllmain_dispatch(HINSTANCE__ * const instance, const unsigned long reason, void * const reserved) Line 293
at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp(293)
sblo.dll!_DllMainCRTStartup(HINSTANCE__ * const instance, const unsigned long reason, void * const reserved) Line 335
at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\dll_dllmain.cpp(335)
ntdll.dll!LdrpCallInitRoutine()
ntdll.dll!LdrpProcessDetachNode()
ntdll.dll!LdrpUnloadNode()
ntdll.dll!LdrpUnloadNode()
ntdll.dll!LdrpUnloadNode()
ntdll.dll!LdrpDecrementModuleLoadCountEx()
ntdll.dll!LdrUnloadDll()
KernelBase.dll!FreeLibrary()
cppunitd_dll.dll!CppUnit::DynamicLibraryManager::doReleaseLibrary() Line 30
at C:\lo\src\core\workdir\UnpackedTarball\cppunit\src\cppunit\Win32DynamicLibraryManager.cpp(30)
cppunitd_dll.dll!CppUnit::DynamicLibraryManager::releaseLibrary() Line 69
at C:\lo\src\core\workdir\UnpackedTarball\cppunit\src\cppunit\DynamicLibraryManager.cpp(69)
cppunitd_dll.dll!CppUnit::DynamicLibraryManager::~DynamicLibraryManager() Line 19
at C:\lo\src\core\workdir\UnpackedTarball\cppunit\src\cppunit\DynamicLibraryManager.cpp(19)
cppunitd_dll.dll!CppUnit::DynamicLibraryManager::`scalar deleting destructor'(unsigned int)
cppunitd_dll.dll!CppUnit::PlugInManager::unload(CppUnit::PlugInManager::PlugInInfo & plugIn) Line 83
at C:\lo\src\core\workdir\UnpackedTarball\cppunit\src\cppunit\PlugInManager.cpp(83)
cppunitd_dll.dll!CppUnit::PlugInManager::~PlugInManager() Line 24
at C:\lo\src\core\workdir\UnpackedTarball\cppunit\src\cppunit\PlugInManager.cpp(24)
cppunittester.exe!`anonymous namespace'::ProtectedFixtureFunctor::run() Line 327
at C:\lo\src\core\sal\cppunittester\cppunittester.cxx(327)
cppunittester.exe!sal_main() Line 466
at C:\lo\src\core\sal\cppunittester\cppunittester.cxx(466)
cppunittester.exe!main(int argc, char * * argv) Line 373
at C:\lo\src\core\sal\cppunittester\cppunittester.cxx(373)
cppunittester.exe!invoke_main() Line 79
at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(79)
cppunittester.exe!__scrt_common_main_seh() Line 288
at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(288)
cppunittester.exe!__scrt_common_main() Line 331
at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(331)
cppunittester.exe!mainCRTStartup() Line 17
at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp(17)
kernel32.dll!BaseThreadInitThunk()
ntdll.dll!RtlUserThreadStart()
Change-Id: I597dc242f71d220bbb42aef2611e4fd7e20a7be6
Reviewed-on: https://gerrit.libreoffice.org/85586
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/basic/inc/sbxbase.hxx b/basic/inc/sbxbase.hxx
index 638ddfbb255c..a4ea06678f27 100644
--- a/basic/inc/sbxbase.hxx
+++ b/basic/inc/sbxbase.hxx
@@ -20,6 +20,9 @@
#ifndef INCLUDED_BASIC_INC_SBXBASE_HXX
#define INCLUDED_BASIC_INC_SBXBASE_HXX
+#include <sal/config.h>
+
+#include <basic/sbxvar.hxx>
#include <i18nlangtag/lang.h>
#include <vcl/errcode.hxx>
@@ -34,6 +37,7 @@ class SbxBasicFormater;
struct SbxAppData
{
ErrCode eErrCode; // Error code
+ SbxVariableRef m_aGlobErr; // Global error object
std::vector<std::unique_ptr<SbxFactory>>
m_Factories;
diff --git a/basic/source/classes/errobject.cxx b/basic/source/classes/errobject.cxx
index ecd6817790f8..b961e16983f7 100644
--- a/basic/source/classes/errobject.cxx
+++ b/basic/source/classes/errobject.cxx
@@ -18,6 +18,7 @@
*/
#include <errobject.hxx>
+#include <sbxbase.hxx>
#include <cppuhelper/implbase.hxx>
#include <com/sun/star/script/XDefaultProperty.hpp>
@@ -192,8 +193,15 @@ SbxErrObject::getUnoErrObject()
SbxVariableRef const &
SbxErrObject::getErrObject()
{
- static SbxVariableRef pGlobErr = new SbxErrObject( "Err", uno::Any( uno::Reference< vba::XErrObject >( new ErrObject() ) ) );
- return pGlobErr;
+ SbxVariableRef& rGlobErr = GetSbxData_Impl().m_aGlobErr;
+ {
+ static osl::Mutex aMutex;
+ osl::MutexGuard aGuard(aMutex);
+ if (!rGlobErr)
+ rGlobErr = new SbxErrObject("Err",
+ uno::Any(uno::Reference<vba::XErrObject>(new ErrObject())));
+ }
+ return rGlobErr;
}
void SbxErrObject::setNumberAndDescription( ::sal_Int32 _number, const OUString& _description )
More information about the Libreoffice-commits
mailing list