]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge branch 'tor-github/pr/1302'
authorGeorge Kadianakis <desnacked@riseup.net>
Mon, 30 Sep 2019 10:47:53 +0000 (13:47 +0300)
committerGeorge Kadianakis <desnacked@riseup.net>
Mon, 30 Sep 2019 10:47:53 +0000 (13:47 +0300)
1  2 
src/lib/err/backtrace.c
src/lib/log/log.c
src/lib/sandbox/sandbox.c

index c2011285c05f420afd3e0d4eb18cee628e261079,2a956e6115be53879963f4d7f4f966b7199f76b4..8bc7e6965cc5c545e2be8fe564fa219236176575
@@@ -193,12 -198,13 +198,10 @@@ static int trap_signals[] = { SIGSEGV, 
  /** Install signal handlers as needed so that when we crash, we produce a
   * useful stack trace. Return 0 on success, -errno on failure. */
  static int
 -install_bt_handler(const char *software)
 +install_bt_handler(void)
  {
-   int trap_signals[] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGSYS,
-                          SIGIO, -1 };
    int i, rv=0;
  
 -  strncpy(bt_version, software, sizeof(bt_version) - 1);
 -  bt_version[sizeof(bt_version) - 1] = 0;
 -
    struct sigaction sa;
  
    memset(&sa, 0, sizeof(sa));
index 4463bff6186d3d5b8b95aefe4945ed7a39779edd,eacd413a534eedb9f07a95267fd6a4b44f120434..d2002f6eae008504f760e50caab29ae9148acfa4
@@@ -832,33 -804,12 +832,36 @@@ logs_free_all(void
    }
  
    /* We _could_ destroy the log mutex here, but that would screw up any logs
-    * that happened between here and the end of execution. */
+    * that happened between here and the end of execution.
+    * If tor is re-initialized, log_mutex_initialized will still be 1. So we
+    * won't trigger any undefined behaviour by trying to re-initialize the
+    * log mutex. */
  }
  
 +/** Close signal-safe log files.
 + * Closing the log files makes the process and OS flush log buffers.
 + *
 + * This function is safe to call from a signal handler. It should only be
 + * called when shutting down the log or err modules. It is currenly called
 + * by the err module, when terminating the process on an abnormal condition.
 + */
 +void
 +logs_close_sigsafe(void)
 +{
 +  logfile_t *victim, *next;
 +  /* We can't LOCK_LOGS() in a signal handler, because it may call
 +   * signal-unsafe functions. And we can't deallocate memory, either. */
 +  next = logfiles;
 +  logfiles = NULL;
 +  while (next) {
 +    victim = next;
 +    next = next->next;
 +    if (victim->needs_close) {
 +      close_log_sigsafe(victim);
 +    }
 +  }
 +}
 +
  /** Remove and free the log entry <b>victim</b> from the linked-list
   * logfiles (it is probably present, but it might not be due to thread
   * racing issues). After this function is called, the caller shouldn't
Simple merge