summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-09-24 11:03:34 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-09-24 13:57:29 +0200
commitfe040e71343cb894f97a0781f77805fd046178ca (patch)
tree209e673e416efaee9595671554eb1f1aacee589c
parentfa89349b360945d726db0c5f85cd4ccb0822417f (diff)
we just want to append to the caught exception and rethrow it
try and avoid using cppu::throwException due to asan AddressSanitizer:DEADLYSIGNAL ================================================================= ==571495==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x7f0af1cee04c bp 0x7ffc0fa694f0 sp 0x7ffc0fa69298 T0) ==571495==The signal is caused by a READ memory access. ==571495==Hint: this fault was caused by a dereference of a high value address (see register values below). Disassemble the provided pc to learn which register was used. #0 0x7f0af1cee04c (<unknown module>) #1 0xab690cf in dbtools::SQLExceptionInfo::doThrow() connectivity/source/commontools/dbexception.cxx:240:9 #2 0xa5e0a26 in dbaccess::ORowSet::impl_ensureStatement_throw() dbaccess/source/core/api/RowSet.cxx:1661:16 #3 0xa5e0d80 in dbaccess::ORowSet::impl_prepareAndExecute_throw() dbaccess/source/core/api/RowSet.cxx:1667:5 #4 0xa5d33c4 in dbaccess::ORowSet::execute_NoApprove_NoNewConn(osl::ResettableGuard<osl::Mutex>&) dbaccess/source/core/api/RowSet.cxx:1800:45 #5 0xa5d0a10 in dbaccess::ORowSet::execute() dbaccess/source/core/api/RowSet.cxx:1556:5 #6 0x6eae94 in ScDocShell::DBaseImport(rtl::OUString const&, unsigned short, std::__1::map<short, ScColWidthParam, std::__1::less<short>, std::__1::allocator<std::__1::pair<short const, ScColWidthParam> > >&, ScFlatBoolRowSegments&) sc/source/ui/docshell/docsh8.cxx:316:18 #7 0x65ba78 in TestImportDBF sc/source/ui/docshell/docsh.cxx:3448:33 #8 0x627912 in LLVMFuzzerTestOneInput vcl/workben/dbffuzzer.cxx:49:11 #9 0x53fe23 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) cxa_noexception.cpp #10 0x53f61a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) cxa_noexception.cpp #11 0x540ccb in fuzzer::Fuzzer::MutateAndTestOne() cxa_noexception.cpp #12 0x5416f5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) cxa_noexception.cpp #13 0x5325ce in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) cxa_noexception.cpp #14 0x557582 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10 #15 0x7f0af28b90b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2) seen in oss-fuzz build with clang version 14.0.0 (https://github.com/llvm/llvm-project.git 0e03450ae4358e8a8242b73d493d96efea9d3ccf) Change-Id: I0d676e10d7749ab331870b3d763e8f0bbefa18c3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122571 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--dbaccess/source/core/api/RowSet.cxx18
-rw-r--r--dbaccess/source/core/api/RowSet.hxx1
2 files changed, 9 insertions, 10 deletions
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index 79ffe82ea2da..6a5af36e205e 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -123,6 +123,7 @@ ORowSet::ORowSet( const Reference< css::uno::XComponentContext >& _rxContext )
,m_aRowsetListeners(*m_pMutex)
,m_aApproveListeners(*m_pMutex)
,m_aRowsChangeListener(*m_pMutex)
+ ,m_sErrorString(ResourceManager::loadString(RID_STR_COMMAND_LEADING_TO_ERROR))
,m_nFetchDirection(FetchDirection::FORWARD)
,m_nFetchSize(50)
,m_nMaxFieldSize(0)
@@ -1644,21 +1645,18 @@ void ORowSet::impl_ensureStatement_throw()
// then the driver doesn't support this feature
}
}
- catch( const SQLException& )
+ catch (SQLException& rException)
{
- SQLExceptionInfo aError( ::cppu::getCaughtException() );
- OSL_ENSURE( aError.isValid(), "ORowSet::impl_makeNewStatement_throw: caught an SQLException which we cannot analyze!" );
+ css::sdbc::SQLException* pLastExceptionInChain = SQLExceptionInfo::getLastException(&rException);
+ assert(pLastExceptionInChain && "will at least be &rException");
// append information about what we were actually going to execute
- try
- {
- OUString sInfo(DBA_RES_PARAM( RID_STR_COMMAND_LEADING_TO_ERROR, "$command$", sCommandToExecute ) );
- aError.append( SQLExceptionInfo::TYPE::SQLContext, sInfo );
- }
- catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION("dbaccess"); }
+ OUString sInfo(m_sErrorString.replaceFirst("$command$", sCommandToExecute));
+ css::uno::Any aAppend = SQLExceptionInfo::createException(SQLExceptionInfo::TYPE::SQLContext, sInfo, OUString(), 0);
+ pLastExceptionInChain->NextException = aAppend;
// propagate
- aError.doThrow();
+ throw;
}
}
diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx
index 6da5fdb2ece1..4dc244d1b5db 100644
--- a/dbaccess/source/core/api/RowSet.hxx
+++ b/dbaccess/source/core/api/RowSet.hxx
@@ -116,6 +116,7 @@ namespace dbaccess
OUString m_aUpdateCatalogName; // is set by a query
OUString m_aUpdateSchemaName; // is set by a query
OUString m_aUpdateTableName; // is set by a query
+ OUString m_sErrorString;
sal_Int32 m_nFetchDirection;
sal_Int32 m_nFetchSize;