If the native upcall comes after starting coreclr shutdown steps, SIGABRT is raised...
authorWoongsuk Cho <ws77.cho@samsung.com>
Mon, 26 Nov 2018 08:12:57 +0000 (17:12 +0900)
committerWoongsuk Cho <ws77.cho@samsung.com>
Mon, 26 Nov 2018 08:12:57 +0000 (17:12 +0900)
To avoid that kind of crash, ignore SIGABRT after starting coreclr shutdown.

NativeLauncher/launcher/dotnet/dotnet_launcher.cc

index c7e28e8..7cd16b9 100644 (file)
@@ -127,12 +127,19 @@ struct sigaction sig_abrt_new;
 struct sigaction sig_abrt_old;
 
 static bool checkOnSigabrt = false;
+static bool checkOnTerminate = false;
 
 static void onSigabrt(int signum)
 {
        // 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);
@@ -403,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)
@@ -418,7 +431,6 @@ void CoreRuntime::dispose()
                __coreclrLib = nullptr;
        }
 
-       finalizePluginManager();
        finalizePathManager();
 
        __envList.clear();