Remove non async-signal-safe function in signal handler 16/231216/7 accepted/tizen/unified/20200423.054618 submit/tizen/20200422.061027
authorYoungHun Kim <yh8004.kim@samsung.com>
Mon, 20 Apr 2020 07:39:12 +0000 (16:39 +0900)
committerYoungHun Kim <yh8004.kim@samsung.com>
Wed, 22 Apr 2020 05:27:49 +0000 (05:27 +0000)
Change-Id: Ia092ae0515d4d28e58d248b041a0944c26a0b9df

server/src/muse_server_signal.c

index 74909e9..1b72ad0 100644 (file)
@@ -30,8 +30,6 @@ static struct sigaction ms_bus_old_action;
 static struct sigaction ms_xcpu_old_action;
 static struct sigaction ms_pipe_old_action;
 
-static GMutex signal_lock;
-
 static void _ms_signal_handler(int signo);
 static void _ms_signal_backtrace(void *arg);
 static void _ms_signal_sigaction(int signo, siginfo_t *si, void *arg);
@@ -74,49 +72,38 @@ static void _ms_signal_backtrace(void *arg)
        ucontext_t *uctxt = NULL;
        Dl_info info;
        char *sym_addr = NULL;
-       char err_msg[MUSE_MSG_LEN_MAX] = {'\0',};
-
-       muse_return_if_fail(arg);
-
-       g_mutex_lock(&signal_lock);
 
-       LOGE("----------BEGIN MUSE DYING MESSAGE----------");
+       if (!arg)
+               return;
 
        tracesize = backtrace(trace, MUSE_MSG_LEN);
-       if (tracesize < 0) {
-               strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
-               LOGE("backtrace error: %s", err_msg);
-       }
+       if (tracesize <= 0)
+               return;
 
        uctxt = (ucontext_t *)arg;
 
-       #if defined(REG_EIP)
+#if defined(REG_EIP)
        trace[1] = (void *) uctxt->uc_mcontext.gregs[REG_EIP];
-       #elif defined(REG_RIP)
+#elif defined(REG_RIP)
        trace[1] = (void *) uctxt->uc_mcontext.gregs[REG_RIP];
-       #endif
+#endif
+
        strings = backtrace_symbols(trace, tracesize);
-       if (!strings) {
-               strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
-               LOGE("backtrace_symbols error: %s", err_msg);
-       } else {
-               /* skip the first stack frame because it just points here. */
-               for (idx = 1; idx < tracesize; idx++) {
-                       sym_addr = g_strstr_len(strings[idx], strlen(strings[idx]), "[0x");
-
-                       memset(&info, 0, sizeof(info));
-                       if (sym_addr && dladdr((const void *)strtoul(sym_addr + 1, NULL, 16), &info) && info.dli_sname)
-                               LOGE("[%u] %s %s", idx - 1, strings[idx], info.dli_sname);
-                       else
-                               LOGE("[%u] %s", idx - 1, strings[idx]);
-               }
-
-               free(strings);
+       if (!strings)
+               return;
+
+       /* skip the first stack frame because it just points here. */
+       for (idx = 1; idx < tracesize; idx++) {
+               sym_addr = g_strstr_len(strings[idx], strlen(strings[idx]), "[0x");
+
+               memset(&info, 0, sizeof(info));
+               if (sym_addr && dladdr((const void *)strtoul(sym_addr + 1, NULL, 16), &info) && info.dli_sname)
+                       LOGE("[%u] %s %s", idx - 1, strings[idx], info.dli_sname);
+               else
+                       LOGE("[%u] %s", idx - 1, strings[idx]);
        }
 
-       LOGE("----------END MUSE DYING MESSAGE----------");
-
-       g_mutex_unlock(&signal_lock);
+       free(strings);
 }
 
 static void _ms_signal_sigaction(int signo, siginfo_t *si, void *arg)