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

Make memory manager initialize before normal C++ global objects.

This commit is contained in:
Adriano dos Santos Fernandes 2021-09-13 13:27:00 -03:00
parent 15b0de76ca
commit 4d28881a6c
2 changed files with 19 additions and 9 deletions

View File

@ -45,6 +45,13 @@
// operator in destructor will cause AV.
#undef DEBUG_INIT
#ifdef WIN_NT
#pragma init_seg(lib)
#define FB_INIT_PRIORITY
#else
#define FB_INIT_PRIORITY __attribute__ ((init_priority (150)))
#endif
static bool dontCleanup = false;
namespace
@ -173,7 +180,7 @@ namespace
}
};
Cleanup global;
Cleanup global FB_INIT_PRIORITY;
#endif //DEBUG_INIT
void init()
@ -208,6 +215,17 @@ namespace
Firebird::MemoryPool::contextPoolInit();
}
class Init
{
public:
Init()
{
init();
}
};
Init initGlobal FB_INIT_PRIORITY;
Firebird::InstanceControl::InstanceList* instanceList = 0;
FPTR_VOID gdsCleanup = 0;
FPTR_VOID gdsShutdown = 0;
@ -216,12 +234,6 @@ namespace
namespace Firebird
{
InstanceControl::InstanceControl()
{
// Initialize required subsystems, including static mutex
init();
}
InstanceControl::InstanceList::InstanceList(DtorPriority p)
: priority(p)
{

View File

@ -55,8 +55,6 @@ public:
PRIORITY_TLS_KEY
};
InstanceControl();
//
// GlobalPtr should not be directly derived from class with virtual functions -
// virtual table for its instances may become invalid in the moment,