From bc796e9c114503830ce73fdc61e1c9e87ce29f32 Mon Sep 17 00:00:00 2001 From: Woongsuk Cho Date: Fri, 20 Sep 2019 10:03:46 +0900 Subject: [PATCH] to prevent crash while process terminate on profiling mode, kill process immedately without coreclr_shutdown --- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 18 +++++++++++++++++- NativeLauncher/launcher/dotnet/dotnet_launcher.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index 57b6005..75a0341 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -256,10 +256,18 @@ CoreRuntime::CoreRuntime(const char* mode) : __hostHandle(nullptr), __domainId(-1), fd(0), - __initialized(false) + __initialized(false), + __isProfileMode(false) { _INFO("Constructor called!!"); + char *env = nullptr; + env = getenv("CORECLR_ENABLE_PROFILING"); + if (env != nullptr && !strcmp(env, "1")) { + _INFO("profiling mode on"); + __isProfileMode = true; + } + // plugin initialize should be called before start loader mainloop. // In case of VD plugins, attaching secure zone is done in the plugin_initialize(). // When attaching to a secure zone, if there is a created thread, it will failed. @@ -277,6 +285,14 @@ CoreRuntime::CoreRuntime(const char* mode) : CoreRuntime::~CoreRuntime() { + // workaround : to prevent crash while process terminate on profiling mode, + // kill process immediately. + // see https://github.com/dotnet/coreclr/issues/26687 + if (__isProfileMode) { + _INFO("shutdown process immediately."); + _exit(0); + } + dispose(); } diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.h b/NativeLauncher/launcher/dotnet/dotnet_launcher.h index e9e6c5d..704070b 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.h +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.h @@ -50,6 +50,7 @@ class CoreRuntime int fd; bool __initialized; bool __enableLogManager; + bool __isProfileMode; }; } // dotnetcore -- 2.7.4