Hi,
Stefan will know this better than I do, but looking at the SOFA
ObjectFactory it looks like it does not provide "unregister"
functionality. So it looks to me that while unloading the DLL of the
simulation plugin (and hence the SOFA Core library) there are still some
dangling pointers in the ObjectFactory. Probably due to some previously
unloaded SOFA modules.
If you really want to get to the bottom of this, I suggest to look at
the list of loaded and unloaded DLLs when debugger breaks into your
application due to the read access violation. Visual Studio provides
this list in the "Modules" view. Please post it here.
A typically workaround is to add the SOFA Core library to the list of
"preloaded" DLLS, such that it is not unloaded during the CTK
PluginFramework initialization.
Best,
Sascha
On 02/23/2017 06:41 PM, Camille Krewcun wrote:
> Hi,
>
> On the last test I made I used the source code cloned from
> https://phabricator.mitk.org/source/mitk.git today (after you merged
> the patch into the master), with no modification nor additional code.
>
> I proceeded to the following build steps:
> - Switched on MITK_USE_SOFA in the superbuild (which forced 3
> boost libraries on), configured twice, generated the solution, and
> built project ALL_BUILD in debug mode
> - Switched in CMake to the MITK-build directory to switch both
> MITK_BUILD_org.mitk.simulation and
> MITK_BUILD_org.mitk.gui.qt.simulation plugins on, configured and
> generated.
> - I opened the solution directly from CMake, then built and run
> MITKWorkbench.
>
> All projects are built successfully (including MitkWorkbench without
> any error, but I encounter an error when running MitkWorkbench (in
> Debug mode). I also tried to use the /BlueBerry.clean argument, with
> the same result.
>
> When I run MitkWorkbench, a pop-up window appears with the following text:
> -------------------------------------------------------------------------------------------------------------------------
> Exception thrown: read access violation.
> this-> was 0x7FFF33F669E8
> If there is a handler for this exception, the program may be safely
> continued.
> -------------------------------------------------------------------------------------------------------------------------
>
> I encounter the error before the interface is visible, and it occurs
> when the plugins are being loaded. Here is the call stack when the
> application crashes:
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SofaCore_1_0d.dll!boost::detail::sp_counted_base::release() Line 103
> SofaCore_1_0d.dll!boost::detail::shared_count::~shared_count() Line 473
> [External Code]
> SofaCore_1_0d.dll!boost::checked_delete<sofa::core::ObjectFactory::ClassEntry>(sofa::core::ObjectFactory::ClassEntry
> * x) Line 34
> SofaCore_1_0d.dll!boost::detail::sp_counted_impl_p<sofa::core::ObjectFactory::ClassEntry>::dispose()
> Line 79
> SofaCore_1_0d.dll!boost::detail::sp_counted_base::release() Line 104
> SofaCore_1_0d.dll!boost::detail::shared_count::~shared_count() Line 473
> [External Code]
> SofaCore_1_0d.dll!sofa::core::ObjectFactory::~ObjectFactory() Line 37
> [External Code]
> Qt5Cored.dll!QLibraryPrivate::unload_sys() Line 151
> Qt5Cored.dll!QLibraryPrivate::unload(QLibraryPrivate::UnloadFlag flag)
> Line 552
> Qt5Cored.dll!QPluginLoader::unload() Line 256
> CTKPluginFramework.dll!ctkPluginStorageSQL::insertArchive(QSharedPointer<ctkPluginArchiveSQL>
> pa, QSqlQuery * query) Line 491
> CTKPluginFramework.dll!ctkPluginStorageSQL::insertArchive(QSharedPointer<ctkPluginArchiveSQL>
> pa) Line 400
> CTKPluginFramework.dll!ctkPluginStorageSQL::insertPlugin(const QUrl &
> location, const QString & localPath) Line 378
> CTKPluginFramework.dll!ctkPlugins::install(const QUrl & location,
> QIODevice * in) Line 119
> CTKPluginFramework.dll!ctkPluginContext::installPlugin(const QUrl &
> location, QIODevice * in) Line 101
> CTKPluginFramework.dll!ctkPluginFrameworkLauncherPrivate::install(const
> QUrl & pluginPath, ctkPluginContext * context) Line 238
> CTKPluginFramework.dll!ctkPluginFrameworkLauncherPrivate::loadBasicPlugins()
> Line 335
> CTKPluginFramework.dll!ctkPluginFrameworkLauncher::startup(QRunnable *
> endSplashHandler) Line 522
> CTKPluginFramework.dll!ctkPluginFrameworkLauncher::run(QRunnable *
> endSplashHandler, const QVariant & argument) Line 423
> MitkAppUtil.dll!mitk::BaseApplication::main(const
> std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char>
> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char>
> > > > & args) Line 701
> PocoUtild.dll!Poco::Util::Application::run() Line 333
> MitkAppUtil.dll!mitk::BaseApplication::run() Line 824
> MitkWorkbench.exe!main(int argc, char * * argv) Line 41
> [External Code]
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> The code crashes when a call is made to method insertArchive in
> ctkPluginStorageSQL.cpp, relatively to the simulation plugin. This
> triggers a call to QPluginLoader::unload() method, and finally results
> in a crash when calling release() method of a Boost smart pointer.
>
> I'll keep investigating but at the moment I don't know why this happens.
>
> I certainly can provide you with more details if you need some.
>
> Best,
>
> Camille
>
> ------------------------------------------------------------------------
> *From: *"Stefan Dinkelacker" <***@dkfz-heidelberg.de>
> *To: *"Camille Krewcun" <***@orange.fr>
> *Cc: *mitk-***@lists.sourceforge.net, "Federico Milano"
> <***@gmail.com>
> *Sent: *Jeudi 23 Février 2017 17:42:30
> *Subject: *AW: [mitk-users] [Simulation plugin] Execution error at
> plugin loading
>
> Hi, I tested successfully on Windows 10 as well. I need more
> information to be able to guess what's going on. Did you modify or add
> code? What's the call stack? Does it work by simply start the
> Workbench with a /BlueBerry.clean argument? When does it crash?
>
>
> Best,
>
> Stefan
>
> ________________________________
> Von: Camille Krewcun <***@orange.fr>
> Gesendet: Donnerstag, 23. Februar 2017 16:01
> An: Dinkelacker, Stefan
> Cc: mitk-***@lists.sourceforge.net; Federico Milano
> Betreff: Re: [mitk-users] [Simulation plugin] Execution error at
> plugin loading
>
> Hi
>
> Thanks for your messages, and for the patch. I had encountered the
> MSVC related error you mentionned before (snprintf, hash_map, and
> eigen) but hadn't gone further.
>
> However I think that the first problem I mentioned with this topic is
> not related to the compiler version, nor to these problems.
> I've just tried to compile (with MSVC 2015) and execute MITK with the
> patch you merged earlier today into master, and although the building
> process is now performed successfully, I still encounter the same
> error (memory access violation) when trying to execute the Workbench.
>
> In addition to that, a colleague of mine successfully reproduced this
> problem on another computer with the following configuration:
> - Windows 10 (version 1607, anniversary update)
> - CMake v3.5.2
> - Qt v5.6.2
> - MITK 2016.11.0 release sources
> - MSVC 2013 Community Update 5
>
> You mentioned that you tested several configurations today: did one of
> these include a Windows 10 environment?
>
> Best,
>
> Camille
>
> ________________________________
> From: "Stefan Dinkelacker" <***@dkfz-heidelberg.de>
> To: "Federico Milano" <***@gmail.com>, "Camille Krewcun"
> <***@orange.fr>
> Cc: mitk-***@lists.sourceforge.net
> Sent: Jeudi 23 Février 2017 12:30:04
> Subject: RE: [mitk-users] [Simulation plugin] Execution error at
> plugin loading
>
> FYI, I tested it today on several configurations and it worked. Merged
> into master.
> Best,
> Stefan
>
> -----Original Message-----
> From: Dinkelacker, Stefan [mailto:***@dkfz-heidelberg.de]
> Sent: Donnerstag, 23. Februar 2017 01:22
> To: Federico Milano; Camille Krewcun
> Cc: mitk-***@lists.sourceforge.net
> Subject: Re: [mitk-users] [Simulation plugin] Execution error at
> plugin loading
>
> Hi,
>
>
> I just gave it a shot with MSVC 2015 and pushed a branch for this[1].
> Seems like it is working now but it needs more testing.
>
>
> Best,
> Stefan
>
>
> [1] https://phabricator.mitk.org/T22551â
>
> ________________________________
> Von: Federico Milano <***@gmail.com>
> Gesendet: Montag, 20. Februar 2017 19:16
> An: Camille Krewcun; Dinkelacker, Stefan
> Cc: mitk-***@lists.sourceforge.net
> Betreff: Re: [mitk-users] [Simulation plugin] Execution error at
> plugin loading
>
> Hi Stefan, Camille,
>
> The issues are not OS related but compiler related. VS 2015 has issues
> with snprintf. Once you solve them you (there's a macro to disable
> that check) you will find issues with the private eigen version of
> SOFA. Those issues are much harder to solve.
>
> If you use Vs 2013 you won't find these issues.
>
> Federico
>
> El El lun, 20 de feb. de 2017 a las 07:25, Dinkelacker, Stefan
> <***@dkfz-heidelberg.de<mailto:***@dkfz-heidelberg.de>>
> escribió:
>
> Hi,
>
>
>
> it was Windows 8.1. Regarding Windows 10, we only have configurations
> with VS2015, but not VS2013. We found some compile errors regarding
> snprintf on these machines today, which I will investigate later today
> or tomorrow.
>
>
>
> Best,
>
> Stefan
>
>
>
> From: Camille Krewcun
> [mailto:***@orange.fr<mailto:***@orange.fr>]
> Sent: Freitag, 17. Februar 2017 17:04
> To: Dinkelacker, Stefan
> Cc:
> mitk-***@lists.sourceforge.net<mailto:mitk-***@lists.sourceforge.net>
>
> Subject: Re: [mitk-users] [Simulation plugin] Execution error at
> plugin loading
>
>
>
> Hi,
>
> As a follow-up to my previous mail, here is what I could give a deeper
> look to:
>
> - I started the building process from the beginning on another
> computer with the same configuration, except for the OS which was
> Microsoft Windows 7 (service pack 1, x64). I didn't encounter the same
> error and was able to successfully launch the Workbench with the
> simulation plugin on.
> - I tried to suppress everything related to MITK on the computer
> running under Windows 10 and started once more, in case there would
> have been a conflict I would not have been aware of. Once again I was
> able to go through all the building process without any error, but
> encountered the same problem (memory access violation) when running
> the Workbench.
> - I finally updated my Windows 10 version with the anniversary
> update (version 1607, build 14393), but this was also unsuccessful.
>
> Considering these elements I would say the problem is likely to come
> either from windows 10 or from conflicting files on my computer I
> couldn't find.
>
> Were you running on Windows 10 when you tried to reproduce the error?
> Or do you know if a test has been made recently on Windows 10 (I saw
> it was part of the Tier 2 supported platforms)?
> Otherwise the problem must be specifically related to something on my
> computer.
>
> Regards,
>
> Camille
>
> ________________________________
>
> From: "Camille Krewcun"
> <***@orange.fr<mailto:***@orange.fr>>
> To: "Stefan Dinkelacker"
> <***@dkfz-heidelberg.de<mailto:***@dkfz-heidelberg.de>>
> Cc:
> mitk-***@lists.sourceforge.net<mailto:mitk-***@lists.sourceforge.net>
> Sent: Mercredi 1 Février 2017 16:18:41
> Subject: Re: [mitk-users] [Simulation plugin] Execution error at
> plugin loading
>
> Hi Stefan,
>
> Thanks for your answer!
>
> I did exactly the same as you described in the first two lines of your
> message (and encountered the same forced switch on for the Boost
> libraries).
>
> As for the things that could have gone wrong:
>
> - I didn't encounter any error during the superbuild (although
> warnings were triggered), and everything was built successfully
> - I used the debug batch file (StartVS_debug.bat) to launch the
> Workbench after compiling in Debug mode. I also tried to do all the
> building process in Release mode (also following the same steps as you
> described), using this time the release batch file, and apparently
> encountered what seems to be the same error.
> - I checked that both simulation plugins (org.mitk.simulation and
> org.gui.qt.simulation) were indeed switched on
>
> I finally tried to delete all the Workbench folders in the AppData
> directory but I still encounter the same error, although not with the
> same callstack as plugins were directly loaded (and not updated).
> However a call to the insertArchive method is also made during this
> loading process, and it triggers the error when used relatively to the
> org.mitk.simulation plugin.
>
> I made a lot of manipulations relatively to MITK lately, and I'm not
> sure that I'm not missing anything. I'll try to reproduce the problem
> in a "clean" machine, starting from 2016.03 sources only, and going
> through the entire building process.
>
> I'll keep you updated if I encounter the error once more.
>
> Best,
>
> Camille
>
> ________________________________
>
> From: "Stefan Dinkelacker"
> <***@dkfz-heidelberg.de<mailto:***@dkfz-heidelberg.de>>
> To: "Camille Krewcun"
> <***@orange.fr<mailto:***@orange.fr>>,
> mitk-***@lists.sourceforge.net<mailto:mitk-***@lists.sourceforge.net>
> Sent: Mercredi 1 Février 2017 15:15:18
> Subject: RE: [mitk-users] [Simulation plugin] Execution error at
> plugin loading
>
> Hi,
>
>
>
> I have just done a superbuild with your setup (2016.03, CMake 3.7, VS
> 2013 Community Update 5, and Qt 5.4.2). I switched on MITK_USE_SOFA in
> the superbuild. Boost with a few libraries were force switched on
> then. I configured again and generated the superbuild solution. I
> built the project MITK-Configure in Debug Configuration, and then
> switched in CMake to the MITK-build directory to switch on the two
> simulation plugins. Configure/Gerenrate. I used the debug batch file
> (!) to open the MITK solution and built/run MITKWorkbench. So
> everything works for me.
>
>
>
> Thing that might have gone wrong in your case:
>
>
>
> - Did you check, that the superbuild was completely successful?
>
> - Did you use the right batch file to open the MITK solution?
>
> - Did you switch on both simulation plugins?
>
> - If youâre sure that everything was built successfully, you can
> either go to %APP_DATA%/../Local/DKFZ and delete all the Workbench
> folders to force a clean start of the Workbench, or pass
> /BlueBerry.clean once as argument to the Workbench, which will do the
> same (remember to remove the argument later). You can add the argument
> in the properties of the MITKWorkbench project (Configuration
> Properties -> Debugging -> Command Arguments).
>
>
>
> Best
>
> Stefan
>
>
>
>
>
>
>
> From: Camille Krewcun [mailto:***@orange.fr]
> Sent: Dienstag, 31. Januar 2017 17:54
> To:
> mitk-***@lists.sourceforge.net<mailto:mitk-***@lists.sourceforge.net>
> Subject: [mitk-users] [Simulation plugin] Execution error at plugin
> loading
>
>
>
> Hello everyone,
>
> I encounter an execution error (memory access violation) when trying
> to launch MITK Workbench with the simulation plugin.
>
> This error seems to result from a call to the insertArchive method of
> ctkPluginStorageSQL (relatively to org.mitk.simulation plugin),
> through the updateDB method. However I have difficulties to trace back
> the exact cause of the problem through the plugin loading process.
>
> Has this situation been encountered before?
>
> I leave more information concerning the error and my environment below.
>
> Best regards,
>
> Camille
>
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> Build information:
>
> Working on Microsoft Windows 10 Professional (original version 10240)
>
> MITK 2016.03 release sources
> CMake 3.7.0
> Visual Studio 2013 Community (Update 5)
> Qt 5.4.2
>
> All third party libraries automatically downloaded and built during
> MITK superbuild
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> Error message:
>
> "Unhandled exception at 0x00007FFF19064FF5 (SofaCore_1_0d.dll) in
> MitkWorkbench.exe: 0xC0000005: Access violation reading location
> 0x00007FFF0A90F530."
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> Callstack when error is triggered:
>
> > SofaCore_1_0d.dll!boost::detail::sp_counted_base::release() Line
> > 103
> SofaCore_1_0d.dll!boost::detail::shared_count::~shared_count() Line 471
> [External Code]
> SofaCore_1_0d.dll!boost::checked_delete<sofa::core::ObjectFactory::ClassEntry>(sofa::core::ObjectFactory::ClassEntry
> * x) Line 34
> SofaCore_1_0d.dll!boost::detail::sp_counted_impl_p<sofa::core::ObjectFactory::ClassEntry>::dispose()
> Line 79
> SofaCore_1_0d.dll!boost::detail::sp_counted_base::release() Line 104
> SofaCore_1_0d.dll!boost::detail::shared_count::~shared_count() Line 471
> [External Code]
> SofaCore_1_0d.dll!sofa::core::ObjectFactory::~ObjectFactory() Line 37
> [External Code]
> Qt5Cored.dll!QLibraryPrivate::unload_sys() Line 150
> Qt5Cored.dll!QLibraryPrivate::unload(QLibraryPrivate::UnloadFlag flag)
> Line 549
> Qt5Cored.dll!QPluginLoader::unload() Line 256
> CTKPluginFramework.dll!ctkPluginStorageSQL::insertArchive(QSharedPointer<ctkPluginArchiveSQL>
> pa, QSqlQuery * query) Line 491
> CTKPluginFramework.dll!ctkPluginStorageSQL::updateDB() Line 333
> CTKPluginFramework.dll!ctkPluginStorageSQL::open() Line 179
> CTKPluginFramework.dll!ctkPluginStorageSQL::ctkPluginStorageSQL(ctkPluginFrameworkContext
> * framework) Line 64
> CTKPluginFramework.dll!ctkPluginFrameworkContext::init() Line 161
> CTKPluginFramework.dll!ctkPluginFrameworkPrivate::init() Line 56
> CTKPluginFramework.dll!ctkPluginFramework::start(const
> QFlags<enum ctkPlugin::StartOption> & options) Line 112
> CTKPluginFramework.dll!ctkPluginFrameworkLauncher::startup(QRunnable *
> __formal) Line 521
> CTKPluginFramework.dll!ctkPluginFrameworkLauncher::run(QRunnable *
> endSplashHandler, const QVariant & argument) Line 425
> MitkAppUtil.dll!mitk::BaseApplication::main(const
> std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char>
> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char>
> > > > & args) Line 686
> PocoUtild.dll!Poco::Util::Application::run() Line 333
> MitkAppUtil.dll!mitk::BaseApplication::run() Line 784
> MitkWorkbench.exe!main(int argc, char * * argv) Line 41
> [External Code]
>
>
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org!
> http://sdm.link/slashdot_______________________________________________
> mitk-users mailing list
> mitk-***@lists.sourceforge.net<mailto:mitk-***@lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/mitk-users
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> mitk-users mailing list
> mitk-***@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mitk-users
>
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
>
>
> _______________________________________________
> mitk-users mailing list
> mitk-***@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mitk-users