diff --git a/extern/cloop/src/tests/test1/CalcCppApi.h b/extern/cloop/src/tests/test1/CalcCppApi.h index bf2d7311e0..3ea664c617 100644 --- a/extern/cloop/src/tests/test1/CalcCppApi.h +++ b/extern/cloop/src/tests/test1/CalcCppApi.h @@ -7,6 +7,23 @@ #define CLOOP_CARG #endif +#ifndef CLOOP_NOEXCEPT +#if __cplusplus >= 201103L +#define CLOOP_NOEXCEPT noexcept +#else +#define CLOOP_NOEXCEPT throw() +#endif +#endif + + +#ifndef CLOOP_CONSTEXPR +#if __cplusplus >= 201103L +#define CLOOP_CONSTEXPR constexpr +#else +#define CLOOP_CONSTEXPR const +#endif +#endif + namespace calc { @@ -34,6 +51,8 @@ namespace calc // Interfaces declarations +#define CALC_IDISPOSABLE_VERSION 1u + class IDisposable { public: @@ -41,7 +60,7 @@ namespace calc { void* cloopDummy[1]; uintptr_t version; - void (CLOOP_CARG *dispose)(IDisposable* self) throw(); + void (CLOOP_CARG *dispose)(IDisposable* self) CLOOP_NOEXCEPT; }; void* cloopDummy[1]; @@ -57,7 +76,7 @@ namespace calc } public: - static const unsigned VERSION = 1; + static CLOOP_CONSTEXPR unsigned VERSION = CALC_IDISPOSABLE_VERSION; void dispose() { @@ -65,13 +84,15 @@ namespace calc } }; +#define CALC_ISTATUS_VERSION 2u + class IStatus : public IDisposable { public: struct VTable : public IDisposable::VTable { - int (CLOOP_CARG *getCode)(const IStatus* self) throw(); - void (CLOOP_CARG *setCode)(IStatus* self, int code) throw(); + int (CLOOP_CARG *getCode)(const IStatus* self) CLOOP_NOEXCEPT; + void (CLOOP_CARG *setCode)(IStatus* self, int code) CLOOP_NOEXCEPT; }; protected: @@ -85,11 +106,11 @@ namespace calc } public: - static const unsigned VERSION = 2; + static CLOOP_CONSTEXPR unsigned VERSION = CALC_ISTATUS_VERSION; - static const int ERROR_1 = 1; - static const int ERROR_2 = 0x2; - static const int ERROR_12 = IStatus::ERROR_1 | IStatus::ERROR_2; + static CLOOP_CONSTEXPR int ERROR_1 = 1; + static CLOOP_CONSTEXPR int ERROR_2 = 0x2; + static CLOOP_CONSTEXPR int ERROR_12 = IStatus::ERROR_1 | IStatus::ERROR_2; int getCode() const { @@ -103,15 +124,17 @@ namespace calc } }; +#define CALC_IFACTORY_VERSION 2u + class IFactory : public IDisposable { public: struct VTable : public IDisposable::VTable { - IStatus* (CLOOP_CARG *createStatus)(IFactory* self) throw(); - ICalculator* (CLOOP_CARG *createCalculator)(IFactory* self, IStatus* status) throw(); - ICalculator2* (CLOOP_CARG *createCalculator2)(IFactory* self, IStatus* status) throw(); - ICalculator* (CLOOP_CARG *createBrokenCalculator)(IFactory* self, IStatus* status) throw(); + IStatus* (CLOOP_CARG *createStatus)(IFactory* self) CLOOP_NOEXCEPT; + ICalculator* (CLOOP_CARG *createCalculator)(IFactory* self, IStatus* status) CLOOP_NOEXCEPT; + ICalculator2* (CLOOP_CARG *createCalculator2)(IFactory* self, IStatus* status) CLOOP_NOEXCEPT; + ICalculator* (CLOOP_CARG *createBrokenCalculator)(IFactory* self, IStatus* status) CLOOP_NOEXCEPT; }; protected: @@ -125,7 +148,7 @@ namespace calc } public: - static const unsigned VERSION = 2; + static CLOOP_CONSTEXPR unsigned VERSION = CALC_IFACTORY_VERSION; IStatus* createStatus() { @@ -158,15 +181,17 @@ namespace calc } }; +#define CALC_ICALCULATOR_VERSION 4u + class ICalculator : public IDisposable { public: struct VTable : public IDisposable::VTable { - int (CLOOP_CARG *sum)(const ICalculator* self, IStatus* status, int n1, int n2) throw(); - int (CLOOP_CARG *getMemory)(const ICalculator* self) throw(); - void (CLOOP_CARG *setMemory)(ICalculator* self, int n) throw(); - void (CLOOP_CARG *sumAndStore)(ICalculator* self, IStatus* status, int n1, int n2) throw(); + int (CLOOP_CARG *sum)(const ICalculator* self, IStatus* status, int n1, int n2) CLOOP_NOEXCEPT; + int (CLOOP_CARG *getMemory)(const ICalculator* self) CLOOP_NOEXCEPT; + void (CLOOP_CARG *setMemory)(ICalculator* self, int n) CLOOP_NOEXCEPT; + void (CLOOP_CARG *sumAndStore)(ICalculator* self, IStatus* status, int n1, int n2) CLOOP_NOEXCEPT; }; protected: @@ -180,7 +205,7 @@ namespace calc } public: - static const unsigned VERSION = 4; + static CLOOP_CONSTEXPR unsigned VERSION = CALC_ICALCULATOR_VERSION; template int sum(StatusType* status, int n1, int n2) const { @@ -223,14 +248,16 @@ namespace calc } }; +#define CALC_ICALCULATOR2_VERSION 6u + class ICalculator2 : public ICalculator { public: struct VTable : public ICalculator::VTable { - int (CLOOP_CARG *multiply)(const ICalculator2* self, IStatus* status, int n1, int n2) throw(); - void (CLOOP_CARG *copyMemory)(ICalculator2* self, const ICalculator* calculator) throw(); - void (CLOOP_CARG *copyMemory2)(ICalculator2* self, const int* address) throw(); + int (CLOOP_CARG *multiply)(const ICalculator2* self, IStatus* status, int n1, int n2) CLOOP_NOEXCEPT; + void (CLOOP_CARG *copyMemory)(ICalculator2* self, const ICalculator* calculator) CLOOP_NOEXCEPT; + void (CLOOP_CARG *copyMemory2)(ICalculator2* self, const int* address) CLOOP_NOEXCEPT; }; protected: @@ -244,7 +271,7 @@ namespace calc } public: - static const unsigned VERSION = 6; + static CLOOP_CONSTEXPR unsigned VERSION = CALC_ICALCULATOR2_VERSION; template int multiply(StatusType* status, int n1, int n2) const { @@ -291,7 +318,7 @@ namespace calc this->cloopVTable = &vTable; } - static void CLOOP_CARG cloopdisposeDispatcher(IDisposable* self) throw() + static void CLOOP_CARG cloopdisposeDispatcher(IDisposable* self) CLOOP_NOEXCEPT { try { @@ -342,7 +369,7 @@ namespace calc this->cloopVTable = &vTable; } - static int CLOOP_CARG cloopgetCodeDispatcher(const IStatus* self) throw() + static int CLOOP_CARG cloopgetCodeDispatcher(const IStatus* self) CLOOP_NOEXCEPT { try { @@ -355,7 +382,7 @@ namespace calc } } - static void CLOOP_CARG cloopsetCodeDispatcher(IStatus* self, int code) throw() + static void CLOOP_CARG cloopsetCodeDispatcher(IStatus* self, int code) CLOOP_NOEXCEPT { try { @@ -367,7 +394,7 @@ namespace calc } } - static void CLOOP_CARG cloopdisposeDispatcher(IDisposable* self) throw() + static void CLOOP_CARG cloopdisposeDispatcher(IDisposable* self) CLOOP_NOEXCEPT { try { @@ -421,7 +448,7 @@ namespace calc this->cloopVTable = &vTable; } - static IStatus* CLOOP_CARG cloopcreateStatusDispatcher(IFactory* self) throw() + static IStatus* CLOOP_CARG cloopcreateStatusDispatcher(IFactory* self) CLOOP_NOEXCEPT { try { @@ -434,7 +461,7 @@ namespace calc } } - static ICalculator* CLOOP_CARG cloopcreateCalculatorDispatcher(IFactory* self, IStatus* status) throw() + static ICalculator* CLOOP_CARG cloopcreateCalculatorDispatcher(IFactory* self, IStatus* status) CLOOP_NOEXCEPT { StatusType status2(status); @@ -449,7 +476,7 @@ namespace calc } } - static ICalculator2* CLOOP_CARG cloopcreateCalculator2Dispatcher(IFactory* self, IStatus* status) throw() + static ICalculator2* CLOOP_CARG cloopcreateCalculator2Dispatcher(IFactory* self, IStatus* status) CLOOP_NOEXCEPT { StatusType status2(status); @@ -464,7 +491,7 @@ namespace calc } } - static ICalculator* CLOOP_CARG cloopcreateBrokenCalculatorDispatcher(IFactory* self, IStatus* status) throw() + static ICalculator* CLOOP_CARG cloopcreateBrokenCalculatorDispatcher(IFactory* self, IStatus* status) CLOOP_NOEXCEPT { StatusType status2(status); @@ -479,7 +506,7 @@ namespace calc } } - static void CLOOP_CARG cloopdisposeDispatcher(IDisposable* self) throw() + static void CLOOP_CARG cloopdisposeDispatcher(IDisposable* self) CLOOP_NOEXCEPT { try { @@ -535,7 +562,7 @@ namespace calc this->cloopVTable = &vTable; } - static int CLOOP_CARG cloopsumDispatcher(const ICalculator* self, IStatus* status, int n1, int n2) throw() + static int CLOOP_CARG cloopsumDispatcher(const ICalculator* self, IStatus* status, int n1, int n2) CLOOP_NOEXCEPT { StatusType status2(status); @@ -550,7 +577,7 @@ namespace calc } } - static int CLOOP_CARG cloopgetMemoryDispatcher(const ICalculator* self) throw() + static int CLOOP_CARG cloopgetMemoryDispatcher(const ICalculator* self) CLOOP_NOEXCEPT { try { @@ -563,7 +590,7 @@ namespace calc } } - static void CLOOP_CARG cloopsetMemoryDispatcher(ICalculator* self, int n) throw() + static void CLOOP_CARG cloopsetMemoryDispatcher(ICalculator* self, int n) CLOOP_NOEXCEPT { try { @@ -575,7 +602,7 @@ namespace calc } } - static void CLOOP_CARG cloopsumAndStoreDispatcher(ICalculator* self, IStatus* status, int n1, int n2) throw() + static void CLOOP_CARG cloopsumAndStoreDispatcher(ICalculator* self, IStatus* status, int n1, int n2) CLOOP_NOEXCEPT { StatusType status2(status); @@ -589,7 +616,7 @@ namespace calc } } - static void CLOOP_CARG cloopdisposeDispatcher(IDisposable* self) throw() + static void CLOOP_CARG cloopdisposeDispatcher(IDisposable* self) CLOOP_NOEXCEPT { try { @@ -648,7 +675,7 @@ namespace calc this->cloopVTable = &vTable; } - static int CLOOP_CARG cloopmultiplyDispatcher(const ICalculator2* self, IStatus* status, int n1, int n2) throw() + static int CLOOP_CARG cloopmultiplyDispatcher(const ICalculator2* self, IStatus* status, int n1, int n2) CLOOP_NOEXCEPT { StatusType status2(status); @@ -663,7 +690,7 @@ namespace calc } } - static void CLOOP_CARG cloopcopyMemoryDispatcher(ICalculator2* self, const ICalculator* calculator) throw() + static void CLOOP_CARG cloopcopyMemoryDispatcher(ICalculator2* self, const ICalculator* calculator) CLOOP_NOEXCEPT { try { @@ -675,7 +702,7 @@ namespace calc } } - static void CLOOP_CARG cloopcopyMemory2Dispatcher(ICalculator2* self, const int* address) throw() + static void CLOOP_CARG cloopcopyMemory2Dispatcher(ICalculator2* self, const int* address) CLOOP_NOEXCEPT { try { @@ -687,7 +714,7 @@ namespace calc } } - static int CLOOP_CARG cloopsumDispatcher(const ICalculator* self, IStatus* status, int n1, int n2) throw() + static int CLOOP_CARG cloopsumDispatcher(const ICalculator* self, IStatus* status, int n1, int n2) CLOOP_NOEXCEPT { StatusType status2(status); @@ -702,7 +729,7 @@ namespace calc } } - static int CLOOP_CARG cloopgetMemoryDispatcher(const ICalculator* self) throw() + static int CLOOP_CARG cloopgetMemoryDispatcher(const ICalculator* self) CLOOP_NOEXCEPT { try { @@ -715,7 +742,7 @@ namespace calc } } - static void CLOOP_CARG cloopsetMemoryDispatcher(ICalculator* self, int n) throw() + static void CLOOP_CARG cloopsetMemoryDispatcher(ICalculator* self, int n) CLOOP_NOEXCEPT { try { @@ -727,7 +754,7 @@ namespace calc } } - static void CLOOP_CARG cloopsumAndStoreDispatcher(ICalculator* self, IStatus* status, int n1, int n2) throw() + static void CLOOP_CARG cloopsumAndStoreDispatcher(ICalculator* self, IStatus* status, int n1, int n2) CLOOP_NOEXCEPT { StatusType status2(status); @@ -741,7 +768,7 @@ namespace calc } } - static void CLOOP_CARG cloopdisposeDispatcher(IDisposable* self) throw() + static void CLOOP_CARG cloopdisposeDispatcher(IDisposable* self) CLOOP_NOEXCEPT { try { diff --git a/extern/cloop/src/tests/test1/CalcPascalApi.pas b/extern/cloop/src/tests/test1/CalcPascalApi.pas index 1b202695c1..28b8a583fb 100644 --- a/extern/cloop/src/tests/test1/CalcPascalApi.pas +++ b/extern/cloop/src/tests/test1/CalcPascalApi.pas @@ -299,6 +299,7 @@ end; function StatusImpl_getCodeDispatcher(this: Status): Integer; cdecl; begin + Result := 0; try Result := StatusImpl(this).getCode(); except @@ -334,6 +335,7 @@ end; function FactoryImpl_createStatusDispatcher(this: Factory): Status; cdecl; begin + Result := nil; try Result := FactoryImpl(this).createStatus(); except @@ -343,6 +345,7 @@ end; function FactoryImpl_createCalculatorDispatcher(this: Factory; status: Status): Calculator; cdecl; begin + Result := nil; try Result := FactoryImpl(this).createCalculator(status); except @@ -352,6 +355,7 @@ end; function FactoryImpl_createCalculator2Dispatcher(this: Factory; status: Status): Calculator2; cdecl; begin + Result := nil; try Result := FactoryImpl(this).createCalculator2(status); except @@ -361,6 +365,7 @@ end; function FactoryImpl_createBrokenCalculatorDispatcher(this: Factory; status: Status): Calculator; cdecl; begin + Result := nil; try Result := FactoryImpl(this).createBrokenCalculator(status); except @@ -387,6 +392,7 @@ end; function CalculatorImpl_sumDispatcher(this: Calculator; status: Status; n1: Integer; n2: Integer): Integer; cdecl; begin + Result := 0; try Result := CalculatorImpl(this).sum(status, n1, n2); except @@ -396,6 +402,7 @@ end; function CalculatorImpl_getMemoryDispatcher(this: Calculator): Integer; cdecl; begin + Result := 0; try Result := CalculatorImpl(this).getMemory(); except @@ -440,6 +447,7 @@ end; function Calculator2Impl_sumDispatcher(this: Calculator2; status: Status; n1: Integer; n2: Integer): Integer; cdecl; begin + Result := 0; try Result := Calculator2Impl(this).sum(status, n1, n2); except @@ -449,6 +457,7 @@ end; function Calculator2Impl_getMemoryDispatcher(this: Calculator2): Integer; cdecl; begin + Result := 0; try Result := Calculator2Impl(this).getMemory(); except @@ -476,6 +485,7 @@ end; function Calculator2Impl_multiplyDispatcher(this: Calculator2; status: Status; n1: Integer; n2: Integer): Integer; cdecl; begin + Result := 0; try Result := Calculator2Impl(this).multiply(status, n1, n2); except diff --git a/src/jrd/CryptoManager.cpp b/src/jrd/CryptoManager.cpp index 0490a190ec..1bce8f1805 100644 --- a/src/jrd/CryptoManager.cpp +++ b/src/jrd/CryptoManager.cpp @@ -823,12 +823,17 @@ namespace Jrd { void CryptoManager::blockingAstChangeCryptState() { - AsyncContextHolder tdbb(&dbb, FB_FUNCTION); - - if (stateLock->lck_physical != CRYPT_CHANGE && stateLock->lck_physical != CRYPT_INIT) + try { - sync.ast(tdbb); + AsyncContextHolder tdbb(&dbb, FB_FUNCTION); + + if (stateLock->lck_physical != CRYPT_CHANGE && stateLock->lck_physical != CRYPT_INIT) + { + sync.ast(tdbb); + } } + catch (const Exception&) + { } } void CryptoManager::doOnAst(thread_db* tdbb) diff --git a/src/jrd/tpc.cpp b/src/jrd/tpc.cpp index f1b059b8eb..c0960a5d5a 100644 --- a/src/jrd/tpc.cpp +++ b/src/jrd/tpc.cpp @@ -705,28 +705,33 @@ int TipCache::tpc_block_blocking_ast(void* arg) { StatusBlockData* data = static_cast(arg); - Database* dbb = data->existenceLock.lck_dbb; - AsyncContextHolder tdbb(dbb, FB_FUNCTION); - - // Should we try to process AST? - if (!data->acceptAst) - return 0; - - TipCache* cache = data->cache; - TraNumber oldest = - cache->m_tpcHeader->getHeader()->oldest_transaction.load(std::memory_order_relaxed); - - // Is data block really old? - if (data->blockNumber >= oldest / cache->m_transactionsPerBlock) - return 0; - - // Release shared memory - if (data->memory) + try { - delete data->memory; - data->memory = NULL; + Database* dbb = data->existenceLock.lck_dbb; + AsyncContextHolder tdbb(dbb, FB_FUNCTION); + + // Should we try to process AST? + if (!data->acceptAst) + return 0; + + TipCache* cache = data->cache; + TraNumber oldest = + cache->m_tpcHeader->getHeader()->oldest_transaction.load(std::memory_order_relaxed); + + // Is data block really old? + if (data->blockNumber >= oldest / cache->m_transactionsPerBlock) + return 0; + + // Release shared memory + if (data->memory) + { + delete data->memory; + data->memory = NULL; + } + LCK_release(tdbb, &data->existenceLock); } - LCK_release(tdbb, &data->existenceLock); + catch (const Exception&) + { } return 0; } diff --git a/src/lock/lock.cpp b/src/lock/lock.cpp index 267368cd41..59fab14dd6 100644 --- a/src/lock/lock.cpp +++ b/src/lock/lock.cpp @@ -1398,7 +1398,19 @@ void LockManager::blocking_action(thread_db* tdbb, SRQ_PTR blocking_owner_offset { // checkout scope LockTableCheckout checkout(this, FB_FUNCTION); EngineCheckout cout(tdbb, FB_FUNCTION, EngineCheckout::UNNECESSARY); - (*routine)(arg); + + try + { + (*routine)(arg); + } + catch (const Exception& ex) + { + iscLogException("Exception from AST routine - this should never happen", ex); + } + catch (...) + { + gds__log("Unknown C++ exception from AST routine - this should never happen"); + } } owner = (own*) SRQ_ABS_PTR(blocking_owner_offset);