If the native upcall comes after starting coreclr shutdown steps, SIGABRT is raised...
[platform/core/dotnet/launcher.git] / NativeLauncher / launcher / dotnet / dotnet_launcher.cc
index d33c0d7..7cd16b9 100644 (file)
@@ -56,7 +56,7 @@ const static std::vector<std::string> RID_FALLBACK_GRAPH =
 #elif defined (__arm__)
 #define ARCHITECTURE_IDENTIFIER "arm"
 const static std::vector<std::string> RID_FALLBACK_GRAPH =
-       {"tizen.4.0.0-armel", "tizen.4.0.0", "tizen-armel", "tizen", "linux-armel", "linux", "unix-armel", "unix", "any", "base"};
+       {"tizen.5.0.0-armel", "tizen.5.0.0", "tizen.4.0.0-armel", "tizen.4.0.0", "tizen-armel", "tizen", "linux-armel", "linux", "unix-armel", "unix", "any", "base"};
 
 #elif defined (__x86_64__)
 #define ARCHITECTURE_IDENTIFIER "x64"
@@ -66,7 +66,7 @@ const static std::vector<std::string> RID_FALLBACK_GRAPH =
 #elif defined (__i386__)
 #define ARCHITECTURE_IDENTIFIER "x86"
 const static std::vector<std::string> RID_FALLBACK_GRAPH =
-       {"linux-x86", "linux", "unix-x86", "unix", "any", "base"};
+       {"tizen.5.0.0-x86", "tizen.5.0.0", "tizen.4.0.0-x86", "tizen.4.0.0", "tizen-x86", "tizen", "linux-x86", "linux", "unix-x86", "unix", "any", "base"};
 
 #else
 #error "Unknown target"
@@ -121,40 +121,53 @@ static void setEnvFromFile()
        }
 }
 
+#define _unused(x) ((void)(x))
+
 struct sigaction sig_abrt_new;
 struct sigaction sig_abrt_old;
 
 static bool checkOnSigabrt = false;
+static bool checkOnTerminate = false;
+
 static void onSigabrt(int signum)
 {
-    fprintf(stderr, "onSigabrt is called!!!\n");
-
-    if (checkOnSigabrt) {
-        fprintf(stderr, "SIGABRT is already handled. Go to exit\n");
-        exit(0);
-    }
-
-    if (hasException()) {
-        fprintf(stderr, "Unhandled exception is occured. Ignore coredump creation and terminate normally\n");
-        exit(0);
-    } else {
-        fprintf(stderr, "SIGABRT from native. raise(%d)\n", signum);
-        checkOnSigabrt = true;
-               if (sigaction(SIGABRT, &sig_abrt_old, NULL) == 0) {
-                       if (raise(signum) < 0) {
-                               fprintf(stderr, "Fail to raise SIGABRT\n");
-                       }
-               } else {
-                       fprintf(stderr, "Fail to set original SIGABRT handler\n");
+       // use unused variable to avoid build warning
+       ssize_t ret = write(STDERR_FILENO, "onSigabrt called\n", 17);
+
+       if (checkOnTerminate) {
+               ret = write(STDERR_FILENO, "onSigabrt called while terminate. go to exit\n", 45);
+               _unused(ret);
+               exit(0);
+       }
+
+       if (checkOnSigabrt) {
+               ret = write(STDERR_FILENO, "onSigabrt called again. go to exit\n", 35);
+               _unused(ret);
+               exit(0);
+       }
+
+       if (hasException()) {
+               ret = write(STDERR_FILENO, "******************************************************\n", 55);
+               ret = write(STDERR_FILENO, "Unhandled exception is occured. check application code\n", 55);
+               ret = write(STDERR_FILENO, "******************************************************\n", 55);
+       }
+
+       checkOnSigabrt = true;
+       if (sigaction(SIGABRT, &sig_abrt_old, NULL) == 0) {
+               if (raise(signum) < 0) {
+                       ret = write(STDERR_FILENO, "Fail to raise SIGABRT\n", 22);
                }
-    }
+       } else {
+               ret = write(STDERR_FILENO, "Fail to set original SIGABRT handler\n", 37);
+       }
+       _unused(ret);
 }
 
 static void registerSigHandler()
 {
        sig_abrt_new.sa_handler = onSigabrt;
-       if (sigemptyset(&sig_abrt_new.sa_mask) == 0) {
-               _ERR("Fail to initialize signal set");
+       if (sigemptyset(&sig_abrt_new.sa_mask) != 0) {
+               _ERR("Fail to sigemptyset");
        }
 
        if (sigaction(SIGABRT, &sig_abrt_new, &sig_abrt_old) < 0) {
@@ -268,6 +281,10 @@ int CoreRuntime::initialize(bool standalone)
        putenv(const_cast<char *>("UNW_ARM_UNWIND_METHOD=6"));
 #endif // __arm__
 
+       // Disable debug pipes and semaphores creation in case of non-standlone mode
+       if (!standalone)
+               putenv(const_cast<char *>("COMPlus_EnableDiagnostics=0"));
+
        // read string from external file and set them to environment value.
        setEnvFromFile();
 
@@ -393,6 +410,12 @@ bool CoreRuntime::initializeCoreClr(const char* appId,
 
 void CoreRuntime::dispose()
 {
+       // call finalize plugin callback before shutdown coreclr
+       finalizePluginManager();
+
+       // ignore the signal generated by an exception that occurred during shutdown
+       checkOnTerminate = true;
+
        if (__hostHandle != nullptr) {
                int st = shutdown(__hostHandle, __domainId);
                if (st < 0)
@@ -408,7 +431,6 @@ void CoreRuntime::dispose()
                __coreclrLib = nullptr;
        }
 
-       finalizePluginManager();
        finalizePathManager();
 
        __envList.clear();