Following up on http://sourceforge.net/mailarchive/message.php?msg_id=31451146
This happens on Windows 7 and 8 (64-bit), compiled with Visual Studio 2010.
Using the ContourModel crash as an example:
- start up our GUI application
- eventually ContourModel.dll loads, runs its initialisers.
- it registers its factories
- other stuff happens
- ContourModel.dll is unloaded, the destructor of the initialiser is run.
- everything fine so far. application continues loading.
- ContourModel.dll is loaded again.
- Its initialiser runs, the constructor constructs its m_Factory member
- calling mitk::CoreObjectFactory::GetInstance()->RegisterExtraFactory(m_Factory) triggers a segfault
In most cases the segfault is due to a null pointer derefence. Sometimes it tries to call a null function pointer. Sometimes the pointer has a value like 0x0000000900000000.
The call stack in case of a crash is (beware of line-breaks):
ITKCommon-4.3.dll!itk::ObjectFactoryBase::CreateInstance(const char * itkclassname) Line 150 + 0x35 bytes C++
ContourModel.dll!itk::ObjectFactory<mitk::ContourObjectFactory>::Create() Line 60 + 0x22 bytes C++ ContourModel.dll!mitk::ContourObjectFactory::New() Line 29 + 0x3c bytes C++ ContourModel.dll!RegisterContourObjectFactory::RegisterContourObjectFactory() Line 142 + 0x31 bytes C++ ContourModel.dll!`dynamic initializer for 'registerContourObjectFactory''() Line 154 + 0x21 bytes C++ msvcr100d.dll!_initterm() + 0x2c bytes ContourModel.dll!_CRT_INIT(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 289 C ContourModel.dll!__DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 506 + 0x13 bytes C ContourModel.dll!_DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 477 C ntdll.dll!LdrpCallInitRoutine() + 0x3f bytes ntdll.dll!LdrpInitializeNode() + 0x192 bytes ntdll.dll!LdrpInitializeGraph() + 0x7b bytes ntdll.dll!LdrpInitializeGraph() + 0xf43 bytes ntdll.dll!LdrpInitializeGraph() + 0xf43 bytes ntdll.dll!LdrpInitializeGraph() + 0xf43 bytes ntdll.dll!LdrpPrepareModuleForExecution() - 0x21 bytes ntdll.dll!LdrpLoadDll() - 0x108a5 bytes ntdll.dll!LdrLoadDll() + 0xa7 bytes KernelBase.dll!LoadLibraryExW() + 0xc3 bytes QtCored4.dll!QLibraryPrivate::load_sys() Line 126 + 0x43 bytes C++ QtCored4.dll!QLibraryPrivate::load() Line 469 + 0xa bytes C++ QtCored4.dll!QLibraryPrivate::loadPlugin() Line 519 + 0xa bytes C++ QtCored4.dll!QPluginLoader::load() Line 228 C++ CTKPluginFramework.dll!ctkPluginStorageSQL::insertArchive(QSharedPointer<ctkPluginArchiveSQL> * pa, QSqlQuery * query) Line 432 + 0xe bytes C++ CTKPluginFramework.dll!ctkPluginStorageSQL::insertArchive(QSharedPointer<ctkPluginArchiveSQL> * pa) Line 401 + 0x3e bytes C++ CTKPluginFramework.dll!ctkPluginStorageSQL::insertPlugin(const QUrl & location, const QString & localPath) Line 379 C++ CTKPluginFramework.dll!ctkPlugins::install(const QUrl & location, QIODevice * in) Line 119 + 0x51 bytes C++ CTKPluginFramework.dll!ctkPluginContext::installPlugin(const QUrl & location, QIODevice * in) Line 101 + 0x23 bytes C++ liborg_blueberry_osgi.dll!berry::InternalPlatform::Initialize(int & argc, char * * argv, Poco::Util::AbstractConfiguration * config) Line 215 + 0x21 bytes C++ liborg_blueberry_osgi.dll!berry::Starter::Run(int & argc, char * * argv, Poco::Util::AbstractConfiguration * config) Line 54 C++ NiftyView.exe!ApplicationMain(int argc, char * * argv, QString * appName, QString * orgName, QString * applicationPlugin) Line 179 + 0x1e bytes C++ NiftyView.exe!main(int argc, char * * argv) Line 23 C++ NiftyView.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C NiftyView.exe!mainCRTStartup() Line 371 C kernel32.dll!BaseThreadInitThunk() + 0x1a bytes ntdll.dll!RtlUserThreadStart() + 0x21 bytes
Depending on which modules get preloaded the crash happens in different DLLs. Always the same type of segfault.
For example, preloading ContourModell results in:
ITKCommon-4.3.dll!itk::ObjectFactoryBase::CreateInstance(const char * itkclassname) Line 150 + 0x35 bytes C++
PlanarFigure.dll!itk::ObjectFactory<mitk::PlanarFigureObjectFactory>::Create() Line 60 + 0x22 bytes C++ PlanarFigure.dll!mitk::PlanarFigureObjectFactory::New() Line 30 + 0x3c bytes C++ PlanarFigure.dll!RegisterPlanarFigureObjectFactory::RegisterPlanarFigureObjectFactory() Line 131 + 0x31 bytes C++ PlanarFigure.dll!`dynamic initializer for 'registerPlanarFigureObjectFactory''() Line 143 + 0x21 bytes C++ msvcr100d.dll!_initterm() + 0x2c bytes PlanarFigure.dll!_CRT_INIT(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 289 C PlanarFigure.dll!__DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 506 + 0x13 bytes C PlanarFigure.dll!_DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 477 C ntdll.dll!LdrpCallInitRoutine() + 0x3f bytes ntdll.dll!LdrpInitializeNode() + 0x192 bytes ntdll.dll!LdrpInitializeGraph() + 0x7b bytes ntdll.dll!LdrpInitializeGraph() + 0xf43 bytes ntdll.dll!LdrpInitializeGraph() + 0xf43 bytes ntdll.dll!LdrpInitializeGraph() + 0xf43 bytes ntdll.dll!LdrpPrepareModuleForExecution() - 0x21 bytes ntdll.dll!LdrpLoadDll() - 0x108a5 bytes ntdll.dll!LdrLoadDll() + 0xa7 bytes KernelBase.dll!LoadLibraryExW() + 0xc3 bytes QtCored4.dll!QLibraryPrivate::load_sys() Line 126 + 0x43 bytes C++ QtCored4.dll!QLibraryPrivate::load() Line 469 + 0xa bytes C++ QtCored4.dll!QLibraryPrivate::loadPlugin() Line 519 + 0xa bytes C++ QtCored4.dll!QPluginLoader::load() Line 228 C++ CTKPluginFramework.dll!ctkPluginStorageSQL::insertArchive(QSharedPointer<ctkPluginArchiveSQL> * pa, QSqlQuery * query) Line 432 + 0xe bytes C++ CTKPluginFramework.dll!ctkPluginStorageSQL::insertArchive(QSharedPointer<ctkPluginArchiveSQL> * pa) Line 401 + 0x3e bytes C++ CTKPluginFramework.dll!ctkPluginStorageSQL::insertPlugin(const QUrl & location, const QString & localPath) Line 379 C++ CTKPluginFramework.dll!ctkPlugins::install(const QUrl & location, QIODevice * in) Line 119 + 0x51 bytes C++ CTKPluginFramework.dll!ctkPluginContext::installPlugin(const QUrl & location, QIODevice * in) Line 101 + 0x23 bytes C++ liborg_blueberry_osgi.dll!berry::InternalPlatform::Initialize(int & argc, char * * argv, Poco::Util::AbstractConfiguration * config) Line 215 + 0x21 bytes C++ liborg_blueberry_osgi.dll!berry::Starter::Run(int & argc, char * * argv, Poco::Util::AbstractConfiguration * config) Line 54 C++ NiftyView.exe!ApplicationMain(int argc, char * * argv, QString * appName, QString * orgName, QString * applicationPlugin) Line 179 + 0x1e bytes C++ NiftyView.exe!main(int argc, char * * argv) Line 23 C++ NiftyView.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C NiftyView.exe!mainCRTStartup() Line 371 C kernel32.dll!BaseThreadInitThunk() + 0x1a bytes ntdll.dll!RtlUserThreadStart() + 0x21 bytes
Preloading both PlanarFigure and ContourModel results in:
ITKCommon-4.3.dll!itk::ObjectFactoryBase::CreateInstance(const char * itkclassname) Line 150 + 0x35 bytes C++
Segmentation.dll!itk::ObjectFactory<mitk::ToolManagerProvider>::Create() Line 60 + 0x22 bytes C++ Segmentation.dll!mitk::ToolManagerProvider::New() Line 67 + 0x3c bytes C++ Segmentation.dll!mitk::SegmentationModuleActivator::Load(us::ModuleContext * context) Line 36 + 0xa bytes C++ CppMicroServices.dll!us::Module::Start() Line 138 C++ CppMicroServices.dll!us::ModuleRegistry::Register(us::ModuleInfo * info) Line 132 C++ Segmentation.dll!us::ModuleInitializer::Register() Line 24 + 0x23 bytes C++ Segmentation.dll!us::ModuleInitializer::ModuleInitializer() Line 24 + 0x167 bytes C++ Segmentation.dll!`dynamic initializer for '_InitializeModule''() Line 24 + 0x21 bytes C++ msvcr100d.dll!_initterm() + 0x2c bytes Segmentation.dll!_CRT_INIT(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 289 C Segmentation.dll!__DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 506 + 0x13 bytes C Segmentation.dll!_DllMainCRTStartup(void * hDllHandle, unsigned long dwReason, void * lpreserved) Line 477 C ntdll.dll!LdrpCallInitRoutine() + 0x3f bytes ntdll.dll!LdrpInitializeNode() + 0x192 bytes ntdll.dll!LdrpInitializeGraph() + 0x7b bytes ntdll.dll!LdrpInitializeGraph() + 0xf43 bytes ntdll.dll!LdrpInitializeGraph() + 0xf43 bytes ntdll.dll!LdrpPrepareModuleForExecution() - 0x21 bytes ntdll.dll!LdrpLoadDll() - 0x108a5 bytes ntdll.dll!LdrLoadDll() + 0xa7 bytes KernelBase.dll!LoadLibraryExW() + 0xc3 bytes QtCored4.dll!QLibraryPrivate::load_sys() Line 126 + 0x43 bytes C++ QtCored4.dll!QLibraryPrivate::load() Line 469 + 0xa bytes C++ QtCored4.dll!QLibraryPrivate::loadPlugin() Line 519 + 0xa bytes C++ QtCored4.dll!QPluginLoader::load() Line 228 C++ CTKPluginFramework.dll!ctkPluginStorageSQL::insertArchive(QSharedPointer<ctkPluginArchiveSQL> * pa, QSqlQuery * query) Line 432 + 0xe bytes C++ CTKPluginFramework.dll!ctkPluginStorageSQL::insertArchive(QSharedPointer<ctkPluginArchiveSQL> * pa) Line 401 + 0x3e bytes C++ CTKPluginFramework.dll!ctkPluginStorageSQL::insertPlugin(const QUrl & location, const QString & localPath) Line 379 C++ CTKPluginFramework.dll!ctkPlugins::install(const QUrl & location, QIODevice * in) Line 119 + 0x51 bytes C++ CTKPluginFramework.dll!ctkPluginContext::installPlugin(const QUrl & location, QIODevice * in) Line 101 + 0x23 bytes C++ liborg_blueberry_osgi.dll!berry::InternalPlatform::Initialize(int & argc, char * * argv, Poco::Util::AbstractConfiguration * config) Line 215 + 0x21 bytes C++ liborg_blueberry_osgi.dll!berry::Starter::Run(int & argc, char * * argv, Poco::Util::AbstractConfiguration * config) Line 54 C++ NiftyView.exe!ApplicationMain(int argc, char * * argv, QString * appName, QString * orgName, QString * applicationPlugin) Line 179 + 0x1e bytes C++ NiftyView.exe!main(int argc, char * * argv) Line 23 C++ NiftyView.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C NiftyView.exe!mainCRTStartup() Line 371 C kernel32.dll!BaseThreadInitThunk() + 0x1a bytes ntdll.dll!RtlUserThreadStart() + 0x21 bytes
Cache is deleted each time.