ImageFileReader<> crashes after ApplicationRegistry::RefreshApplicationFactories() is called
Mantis Issue 1082, reported by salbert, assigned to gpasero, created: 2015-10-12
otb::ImageFileReader<>::GenerateOutputInformation() crashes (because L281 ImageIOFactory::CreateImageIO() returns NULL) after otb::ApplicationRegistry::RefreshApplicationFactories() is called (and which then calls itk::ObjectFactoryBase::ReHash()).
See:
- otb::ImageIOFactory::CreateImageIO(); and
- otb::ImageIOFactory::RegisterBuiltInFactories() (especially L91: static bool firstTime local variable).
This issue is similar for all Factory::CreateIO() which call a ::RegisterBuiltFactory() static method using a static bool firstTime local variable.
Note: removing the "first-time" test leads to performance loss.
1444653134 - gpaseroAfter discussions with Stephane, this issue could be solved by avoiding the call to ReHash() and "manually" registering application factories. The fix will be developed on a separate branch as it involves the core of the application engine.
1444726977 - gpaseroThis solution doesn't work well. The factories can be created manually in ApplicationRegistry but their attributes m_LibraryHandle and m_LibraryPath are private, they can't be set so it is hazardous to register them. ITK will consider them as internal libraries.
1445009554 - gpaseroProposed fix in branch mantis-1082 :
- avoid ReHash since we now use the OTB_APPLICATION_PATH.
- we don't try to register in ITK, factories loaded in OTB code.
- when we manually create Application from shared libs, store a pair (Application*, LibHandle*) in a static list.
- at program closure, release all handles
- we add a callback on Application so that it unregisters itself from static list during delete.
Next :
- call a method t