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

This should fix bug CORE-5615 : Firebird 3 crashing randomly

This commit is contained in:
hvlad 2017-11-01 12:11:20 +02:00
parent c4854c02ab
commit 9c66f3c8d0
6 changed files with 26 additions and 10 deletions

View File

@ -231,6 +231,19 @@ namespace Jrd
dbb_flags &= ~(DBB_sweep_in_progress | DBB_sweep_starting);
}
void Database::registerModule(Module& module)
{
Sync sync(&dbb_modules_sync, FB_FUNCTION);
sync.lock(SYNC_SHARED);
if (dbb_modules.exist(module))
return;
sync.unlock();
sync.lock(SYNC_EXCLUSIVE);
if (!dbb_modules.exist(module))
dbb_modules.add(module);
}
void Database::SharedCounter::shutdown(thread_db* tdbb)
{
for (size_t i = 0; i < TOTAL_ITEMS; i++)

View File

@ -398,7 +398,11 @@ public:
MonitoringData* dbb_monitoring_data; // monitoring data
private:
Firebird::SyncObject dbb_modules_sync;
DatabaseModules dbb_modules; // external function/filter modules
public:
ExtEngineManager dbb_extManager; // external engine manager
Firebird::SyncObject dbb_flush_count_mutex;
@ -497,6 +501,8 @@ public:
void deletePool(MemoryPool* pool);
void registerModule(Module&);
private:
Database(MemoryPool* p, Firebird::IPluginConfig* pConf, bool shared)
: dbb_permanent(p),

View File

@ -389,7 +389,7 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
if (!X.RDB$MODULE_NAME.NULL && !X.RDB$ENTRYPOINT.NULL)
{
function->fun_entrypoint =
Module::lookup(X.RDB$MODULE_NAME, X.RDB$ENTRYPOINT, dbb->dbb_modules);
Module::lookup(X.RDB$MODULE_NAME, X.RDB$ENTRYPOINT, dbb);
// Could not find a function with given MODULE, ENTRYPOINT.
// Try the list of internally implemented functions.

View File

@ -165,7 +165,7 @@ namespace Jrd
}
FPTR_INT Module::lookup(const char* module, const char* name, DatabaseModules& interest)
FPTR_INT Module::lookup(const char* module, const char* name, Database* dbb)
{
// Try to find loadable module
Module m = lookupModule(module);
@ -178,12 +178,7 @@ namespace Jrd
terminate_at_space(symbol, name);
void* rc = m.lookupSymbol(symbol);
if (rc)
{
if (!interest.exist(m))
{
interest.add(m);
}
}
dbb->registerModule(m);
return (FPTR_INT)rc;
}

View File

@ -35,6 +35,8 @@
namespace Jrd
{
class Database;
class Module
{
private:
@ -105,7 +107,7 @@ namespace Jrd
~Module();
// used for UDF/BLOB Filter
static FPTR_INT lookup(const char*, const char*, Firebird::SortedObjectsArray<Module>&);
static FPTR_INT lookup(const char*, const char*, Database*);
bool operator>(const Module &im) const;

View File

@ -2264,7 +2264,7 @@ BlobFilter* MET_lookup_filter(thread_db* tdbb, SSHORT from, SSHORT to)
X.RDB$OUTPUT_SUB_TYPE EQ to
{
filter = (FPTR_BFILTER_CALLBACK)
Module::lookup(X.RDB$MODULE_NAME, X.RDB$ENTRYPOINT, dbb->dbb_modules);
Module::lookup(X.RDB$MODULE_NAME, X.RDB$ENTRYPOINT, dbb);
if (filter)
{
blf = FB_NEW_POOL(*dbb->dbb_permanent) BlobFilter(*dbb->dbb_permanent);