to prevent crash while process terminate on profiling mode, kill process immedately...
[platform/core/dotnet/launcher.git] / NativeLauncher / launcher / dotnet / dotnet_launcher.cc
index 57b6005..75a0341 100644 (file)
@@ -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();
 }