From: Woongsuk Cho Date: Tue, 4 Dec 2018 06:56:46 +0000 (+0900) Subject: Sometimes a process terminates abnormally due to a signal generated during coreclr_sh... X-Git-Tag: accepted/tizen/5.0/unified/20181214.065308~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0727ca64ea80a2ca5588c849c4ed164649173cb3;p=platform%2Fcore%2Fdotnet%2Flauncher.git Sometimes a process terminates abnormally due to a signal generated during coreclr_shutdown. In order to handle this situation, plugin must get notification before coreclr_shutdown. So, call pluginFinalize before coreclr_shutdown. And unload the plugin library after coreclr_shutdown() to avoid breaking the signal chain. --- diff --git a/NativeLauncher/inc/plugin_manager.h b/NativeLauncher/inc/plugin_manager.h index f029750..534e0f8 100644 --- a/NativeLauncher/inc/plugin_manager.h +++ b/NativeLauncher/inc/plugin_manager.h @@ -51,6 +51,7 @@ void pluginSetAppInfo(const char* appId, const char* managedAssemblyPath); void pluginSetCoreclrInfo(void* hostHandle, unsigned int domainId, coreclr_create_delegate_ptr delegateFunc); char* pluginGetDllPath(); void pluginBeforeExecute(); +void pluginFinalize(); // initialize / finalize plugin manager int initializePluginManager(const char* mode); diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index 7cd16b9..b0f78c5 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -410,8 +410,9 @@ bool CoreRuntime::initializeCoreClr(const char* appId, void CoreRuntime::dispose() { - // call finalize plugin callback before shutdown coreclr - finalizePluginManager(); + // call plugin finalize function to notify finalize to plugin + // dlclose shoud be done after coreclr shutdown to avoid breaking signal chain + pluginFinalize(); // ignore the signal generated by an exception that occurred during shutdown checkOnTerminate = true; @@ -431,6 +432,7 @@ void CoreRuntime::dispose() __coreclrLib = nullptr; } + finalizePluginManager(); finalizePathManager(); __envList.clear(); diff --git a/NativeLauncher/util/plugin_manager.cc b/NativeLauncher/util/plugin_manager.cc index 227e0a2..44b401d 100644 --- a/NativeLauncher/util/plugin_manager.cc +++ b/NativeLauncher/util/plugin_manager.cc @@ -55,10 +55,8 @@ int initializePluginManager(const char* mode) void finalizePluginManager() { + _INFO("Plugin manager finalize called"); if (__pluginFunc) { - if (__pluginFunc->finalize) { - __pluginFunc->finalize(); - } free(__pluginFunc); __pluginFunc = NULL; } @@ -115,3 +113,10 @@ void pluginBeforeExecute() } } +void pluginFinalize() +{ + if (__pluginFunc && __pluginFunc->finalize) { + __pluginFunc->finalize(); + } +} +