From: Роман Михайлович Русяев/AI Tools Lab /SRR/Staff Engineer/삼성전자 Date: Mon, 10 Sep 2018 10:49:30 +0000 (+0300) Subject: Not unload plugins when they have already done (#1426) X-Git-Tag: nncc_backup~1876 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0cd32ef4dd5303ba9e54aa9ffa6c8f816eb20fdc;p=platform%2Fcore%2Fml%2Fnnfw.git Not unload plugins when they have already done (#1426) workaround for bugs: #1300, #1198 Signed-off-by: Roman Rusyaev --- diff --git a/contrib/nnc/include/support/shared_library.h b/contrib/nnc/include/support/shared_library.h index c9d9aae..497dd37 100644 --- a/contrib/nnc/include/support/shared_library.h +++ b/contrib/nnc/include/support/shared_library.h @@ -103,11 +103,15 @@ void SharedLibrary::unloadLibrary() // reset errors dlerror(); + // This is a workaround for bug when nnc is received segfault when it can access + // to vtable from unloaded plugin. When we eliminate plugins it will be fixed + /* // close the library if ( dlclose(_handle) ) { throw ExceptionT("Cannot unloaded library: '" + _path + "' : " + dlerror()); } + */ } // unloadLibrary diff --git a/contrib/nnc/unittests/module/PluginManager.cpp b/contrib/nnc/unittests/module/PluginManager.cpp index 2f7652d..135037c 100644 --- a/contrib/nnc/unittests/module/PluginManager.cpp +++ b/contrib/nnc/unittests/module/PluginManager.cpp @@ -39,49 +39,26 @@ TEST(CONTRIB_NNC, PluginManager) EXPECT_TRUE(os.str() == plugin ); } -// Unload shared library -static void unloadShared(std::string plugin_path) -{ - void *handle = dlopen(plugin_path.c_str(), RTLD_LAZY); - assert(handle); - - // try to close library until it is closed - for ( int i = 0; !dlclose(handle) && i < 10; i++ ) ; - -} // unloadShared - -// Test PluginManager that destructor throws exception correctly -TEST(SUPPORT_NNC, verifyPluginManager4UnloadPlugin) +// Test PluginManager that destructor doesn't throw exception +TEST(SUPPORT_NNC, verifyPluginManagerForLoadPlugin) { std::string plugin_path{STRING(CMAKE_SAMPLE_PLUGIN_ABS_PATH)}; - bool is_thrown = false; - // test that destructor throws exception try { // load the library PluginManager pluginManager(plugin_path); - - // unload the library directly - unloadShared(plugin_path); } catch ( const PluginException &e ) { - // the exception must be thrown from destructor because the library is already unloaded - is_thrown = true; + FAIL(); } - ASSERT_EQ(is_thrown, true); - - // test that destructor doesn't throw exception while stack is unwinding try { // load the library PluginManager pluginManager(plugin_path); - // unload the library directly - unloadShared(plugin_path); - throw PluginException("test exception"); } catch (const PluginException &e)