8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 22:43:03 +01:00

Fixed #8039: Segfault when opening damaged (last TIP is missing in RDB$PAGES) database

This commit is contained in:
AlexPeshkoff 2024-03-11 19:03:17 +03:00
parent 4fb6643907
commit 593d350807
3 changed files with 22 additions and 4 deletions

View File

@ -464,6 +464,25 @@ namespace Jrd
dbb_filename, dbb_config));
}
void Database::startTipCache(thread_db* tdbb)
{
fb_assert(!dbb_tip_cache);
TipCache* cache = FB_NEW_POOL(*dbb_permanent) TipCache(this);
try
{
cache->initializeTpc(tdbb);
}
catch(const Exception&)
{
cache->finalizeTpc(tdbb);
delete cache;
throw;
}
dbb_tip_cache = cache;
}
// Database::Linger class implementation
void Database::Linger::handler()

View File

@ -666,6 +666,7 @@ public:
static int replStateAst(void*);
const CoercionArray *getBindings() const;
void startTipCache(thread_db* tdbb);
void initGlobalObjects();
void shutdownGlobalObjects();

View File

@ -1851,8 +1851,7 @@ JAttachment* JProvider::internalAttach(CheckStatusWrapper* user_status, const ch
// Initialize TIP cache. We do this late to give SDW a chance to
// work while we read states for all interesting transactions
dbb->dbb_tip_cache = FB_NEW_POOL(*dbb->dbb_permanent) TipCache(dbb);
dbb->dbb_tip_cache->initializeTpc(tdbb);
dbb->startTipCache(tdbb);
// linger
dbb->dbb_linger_seconds = MET_get_linger(tdbb);
@ -3164,8 +3163,7 @@ JAttachment* JProvider::createDatabase(CheckStatusWrapper* user_status, const ch
config->notify();
// Initialize TIP cache
dbb->dbb_tip_cache = FB_NEW_POOL(*dbb->dbb_permanent) TipCache(dbb);
dbb->dbb_tip_cache->initializeTpc(tdbb);
dbb->startTipCache(tdbb);
// Init complete - we can release dbInitMutex
dbb->dbb_flags &= ~(DBB_new | DBB_creating);