8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 06:43:04 +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); 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) void Database::SharedCounter::shutdown(thread_db* tdbb)
{ {
for (size_t i = 0; i < TOTAL_ITEMS; i++) for (size_t i = 0; i < TOTAL_ITEMS; i++)

View File

@ -398,7 +398,11 @@ public:
MonitoringData* dbb_monitoring_data; // monitoring data MonitoringData* dbb_monitoring_data; // monitoring data
private:
Firebird::SyncObject dbb_modules_sync;
DatabaseModules dbb_modules; // external function/filter modules DatabaseModules dbb_modules; // external function/filter modules
public:
ExtEngineManager dbb_extManager; // external engine manager ExtEngineManager dbb_extManager; // external engine manager
Firebird::SyncObject dbb_flush_count_mutex; Firebird::SyncObject dbb_flush_count_mutex;
@ -497,6 +501,8 @@ public:
void deletePool(MemoryPool* pool); void deletePool(MemoryPool* pool);
void registerModule(Module&);
private: private:
Database(MemoryPool* p, Firebird::IPluginConfig* pConf, bool shared) Database(MemoryPool* p, Firebird::IPluginConfig* pConf, bool shared)
: dbb_permanent(p), : 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) if (!X.RDB$MODULE_NAME.NULL && !X.RDB$ENTRYPOINT.NULL)
{ {
function->fun_entrypoint = 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. // Could not find a function with given MODULE, ENTRYPOINT.
// Try the list of internally implemented functions. // 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 // Try to find loadable module
Module m = lookupModule(module); Module m = lookupModule(module);
@ -178,12 +178,7 @@ namespace Jrd
terminate_at_space(symbol, name); terminate_at_space(symbol, name);
void* rc = m.lookupSymbol(symbol); void* rc = m.lookupSymbol(symbol);
if (rc) if (rc)
{ dbb->registerModule(m);
if (!interest.exist(m))
{
interest.add(m);
}
}
return (FPTR_INT)rc; return (FPTR_INT)rc;
} }

View File

@ -35,6 +35,8 @@
namespace Jrd namespace Jrd
{ {
class Database;
class Module class Module
{ {
private: private:
@ -105,7 +107,7 @@ namespace Jrd
~Module(); ~Module();
// used for UDF/BLOB Filter // 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; 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 X.RDB$OUTPUT_SUB_TYPE EQ to
{ {
filter = (FPTR_BFILTER_CALLBACK) 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) if (filter)
{ {
blf = FB_NEW_POOL(*dbb->dbb_permanent) BlobFilter(*dbb->dbb_permanent); blf = FB_NEW_POOL(*dbb->dbb_permanent) BlobFilter(*dbb->dbb_permanent);