2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-17 12:30:48 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2010-04-26 11:55:58 +01:00
|
|
|
|
2021-01-03 12:49:37 +01:00
|
|
|
#include <sal/config.h>
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
|
2017-10-09 17:04:39 +03:00
|
|
|
#include <errobject.hxx>
|
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@collabora.com>
2019-12-20 12:49:04 +03:00
|
|
|
#include <sbxbase.hxx>
|
2010-03-29 09:39:35 +01:00
|
|
|
|
2015-07-02 17:14:33 +09:00
|
|
|
#include <cppuhelper/implbase.hxx>
|
2010-03-29 09:39:35 +01:00
|
|
|
#include <com/sun/star/script/XDefaultProperty.hpp>
|
2017-10-09 17:04:39 +03:00
|
|
|
#include <sbintern.hxx>
|
|
|
|
#include <runtime.hxx>
|
2010-03-29 09:39:35 +01:00
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::ooo;
|
|
|
|
|
2015-08-03 15:13:20 +02:00
|
|
|
class ErrObject : public ::cppu::WeakImplHelper< vba::XErrObject,
|
|
|
|
script::XDefaultProperty >
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
2012-12-30 13:07:28 -02:00
|
|
|
OUString m_sHelpFile;
|
|
|
|
OUString m_sSource;
|
|
|
|
OUString m_sDescription;
|
2010-03-29 09:39:35 +01:00
|
|
|
sal_Int32 m_nNumber;
|
|
|
|
sal_Int32 m_nHelpContext;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ErrObject();
|
2016-11-23 18:37:02 +01:00
|
|
|
|
2010-03-29 09:39:35 +01:00
|
|
|
// Attributes
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual ::sal_Int32 SAL_CALL getNumber() override;
|
|
|
|
virtual void SAL_CALL setNumber( ::sal_Int32 _number ) override;
|
|
|
|
virtual ::sal_Int32 SAL_CALL getHelpContext() override;
|
|
|
|
virtual void SAL_CALL setHelpContext( ::sal_Int32 _helpcontext ) override;
|
|
|
|
virtual OUString SAL_CALL getHelpFile() override;
|
|
|
|
virtual void SAL_CALL setHelpFile( const OUString& _helpfile ) override;
|
|
|
|
virtual OUString SAL_CALL getDescription() override;
|
|
|
|
virtual void SAL_CALL setDescription( const OUString& _description ) override;
|
|
|
|
virtual OUString SAL_CALL getSource() override;
|
|
|
|
virtual void SAL_CALL setSource( const OUString& _source ) override;
|
2010-03-29 09:39:35 +01:00
|
|
|
|
|
|
|
// Methods
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual void SAL_CALL Clear( ) override;
|
|
|
|
virtual void SAL_CALL Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext ) override;
|
2010-03-29 09:39:35 +01:00
|
|
|
// XDefaultProperty
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual OUString SAL_CALL getDefaultPropertyName( ) override;
|
2010-05-07 10:54:26 +01:00
|
|
|
|
|
|
|
// Helper method
|
2017-01-19 18:00:50 +01:00
|
|
|
/// @throws css::uno::RuntimeException
|
2010-05-07 10:54:26 +01:00
|
|
|
void setData( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description,
|
2017-01-26 12:28:58 +01:00
|
|
|
const uno::Any& HelpFile, const uno::Any& HelpContext );
|
2010-03-29 09:39:35 +01:00
|
|
|
};
|
|
|
|
|
2010-05-07 10:54:26 +01:00
|
|
|
ErrObject::ErrObject() : m_nNumber(0), m_nHelpContext(0)
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Int32 SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::getNumber()
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
|
|
|
return m_nNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::setNumber( ::sal_Int32 _number )
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
2017-05-08 14:17:56 +02:00
|
|
|
GetSbData()->pInst->setErrorVB( _number );
|
2012-12-30 13:07:28 -02:00
|
|
|
OUString _description = GetSbData()->pInst->GetErrorMsg();
|
2017-02-03 08:54:47 +02:00
|
|
|
setData( uno::Any( _number ), uno::Any(), uno::Any( _description ), uno::Any(), uno::Any() );
|
2010-03-29 09:39:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
::sal_Int32 SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::getHelpContext()
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
|
|
|
return m_nHelpContext;
|
|
|
|
}
|
|
|
|
void SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::setHelpContext( ::sal_Int32 _helpcontext )
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
|
|
|
m_nHelpContext = _helpcontext;
|
|
|
|
}
|
|
|
|
|
2012-12-30 13:07:28 -02:00
|
|
|
OUString SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::getHelpFile()
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
|
|
|
return m_sHelpFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::setHelpFile( const OUString& _helpfile )
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
|
|
|
m_sHelpFile = _helpfile;
|
|
|
|
}
|
|
|
|
|
2012-12-30 13:07:28 -02:00
|
|
|
OUString SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::getDescription()
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
|
|
|
return m_sDescription;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::setDescription( const OUString& _description )
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
|
|
|
m_sDescription = _description;
|
|
|
|
}
|
|
|
|
|
2012-12-30 13:07:28 -02:00
|
|
|
OUString SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::getSource()
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
|
|
|
return m_sSource;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::setSource( const OUString& _source )
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
|
|
|
m_sSource = _source;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::Clear( )
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
2014-11-12 14:24:10 +05:30
|
|
|
m_sHelpFile.clear();
|
2010-03-29 09:39:35 +01:00
|
|
|
m_sSource = m_sHelpFile;
|
|
|
|
m_sDescription = m_sSource;
|
|
|
|
m_nNumber = 0;
|
|
|
|
m_nHelpContext = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::Raise( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext )
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
2010-05-07 10:54:26 +01:00
|
|
|
setData( Number, Source, Description, HelpFile, HelpContext );
|
2010-03-29 09:39:35 +01:00
|
|
|
if ( m_nNumber )
|
2012-01-15 16:15:08 +01:00
|
|
|
GetSbData()->pInst->ErrorVB( m_nNumber, m_sDescription );
|
2010-03-29 09:39:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// XDefaultProperty
|
2012-12-30 13:07:28 -02:00
|
|
|
OUString SAL_CALL
|
2017-01-26 12:28:58 +01:00
|
|
|
ErrObject::getDefaultPropertyName( )
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
2019-07-30 17:58:25 +02:00
|
|
|
return "Number";
|
2010-03-29 09:39:35 +01:00
|
|
|
}
|
|
|
|
|
2010-05-07 10:54:26 +01:00
|
|
|
void ErrObject::setData( const uno::Any& Number, const uno::Any& Source, const uno::Any& Description, const uno::Any& HelpFile, const uno::Any& HelpContext )
|
|
|
|
{
|
|
|
|
if ( !Number.hasValue() )
|
2014-05-23 12:03:21 +02:00
|
|
|
throw uno::RuntimeException("Missing Required Parameter" );
|
2010-05-07 10:54:26 +01:00
|
|
|
Number >>= m_nNumber;
|
|
|
|
Description >>= m_sDescription;
|
|
|
|
Source >>= m_sSource;
|
|
|
|
HelpFile >>= m_sHelpFile;
|
|
|
|
HelpContext >>= m_nHelpContext;
|
|
|
|
}
|
|
|
|
|
2010-03-29 09:39:35 +01:00
|
|
|
// SbxErrObject
|
2013-04-26 17:14:48 +02:00
|
|
|
SbxErrObject::SbxErrObject( const OUString& rName, const uno::Any& rUnoObj )
|
2010-05-07 10:54:26 +01:00
|
|
|
: SbUnoObject( rName, rUnoObj )
|
2015-11-10 10:10:36 +01:00
|
|
|
, m_pErrObject( nullptr )
|
2010-03-29 09:39:35 +01:00
|
|
|
{
|
|
|
|
rUnoObj >>= m_xErr;
|
|
|
|
if ( m_xErr.is() )
|
2010-05-07 10:54:26 +01:00
|
|
|
{
|
2010-03-29 09:39:35 +01:00
|
|
|
SetDfltProperty( uno::Reference< script::XDefaultProperty >( m_xErr, uno::UNO_QUERY_THROW )->getDefaultPropertyName() ) ;
|
2010-05-07 10:54:26 +01:00
|
|
|
m_pErrObject = static_cast< ErrObject* >( m_xErr.get() );
|
|
|
|
}
|
2010-03-29 09:39:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SbxErrObject::~SbxErrObject()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-07-18 09:22:27 +02:00
|
|
|
uno::Reference< vba::XErrObject > const &
|
2010-03-29 09:39:35 +01:00
|
|
|
SbxErrObject::getUnoErrObject()
|
|
|
|
{
|
2016-10-05 22:00:51 +02:00
|
|
|
SbxErrObject* pGlobErr = static_cast< SbxErrObject* >( getErrObject().get() );
|
2010-03-29 09:39:35 +01:00
|
|
|
return pGlobErr->m_xErr;
|
|
|
|
}
|
|
|
|
|
2016-07-18 09:22:27 +02:00
|
|
|
SbxVariableRef const &
|
2010-03-29 09:39:35 +01:00
|
|
|
SbxErrObject::getErrObject()
|
|
|
|
{
|
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@collabora.com>
2019-12-20 12:49:04 +03:00
|
|
|
SbxVariableRef& rGlobErr = GetSbxData_Impl().m_aGlobErr;
|
|
|
|
{
|
2021-01-03 12:49:37 +01:00
|
|
|
static std::mutex aMutex;
|
|
|
|
std::scoped_lock aGuard(aMutex);
|
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@collabora.com>
2019-12-20 12:49:04 +03:00
|
|
|
if (!rGlobErr)
|
|
|
|
rGlobErr = new SbxErrObject("Err",
|
|
|
|
uno::Any(uno::Reference<vba::XErrObject>(new ErrObject())));
|
|
|
|
}
|
|
|
|
return rGlobErr;
|
2010-03-29 09:39:35 +01:00
|
|
|
}
|
|
|
|
|
2012-11-06 23:34:23 -06:00
|
|
|
void SbxErrObject::setNumberAndDescription( ::sal_Int32 _number, const OUString& _description )
|
2010-05-07 10:54:26 +01:00
|
|
|
{
|
2015-11-10 10:10:36 +01:00
|
|
|
if( m_pErrObject != nullptr )
|
2012-11-03 09:07:25 -05:00
|
|
|
{
|
2017-02-03 08:54:47 +02:00
|
|
|
m_pErrObject->setData( uno::Any( _number ), uno::Any(), uno::Any( _description ), uno::Any(), uno::Any() );
|
2012-11-03 09:07:25 -05:00
|
|
|
}
|
2010-05-07 10:54:26 +01:00
|
|
|
}
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|