PR 78534, 83704 Handle large formatted I/O
[gcc.git] / libgfortran / runtime / backtrace.c
index a61363af2a6cdadede282d2dd1696e1e6fa0a232..b8246889fdeb85d04e88d90b7808bbebff276414 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2006-2018 Free Software Foundation, Inc.
    Contributed by François-Xavier Coudert
 
 This file is part of the GNU Fortran runtime library (libgfortran).
@@ -24,8 +24,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #include "libgfortran.h"
 
+#include <gthr.h>
+
 #include <string.h>
-#include <stdlib.h>
 #include <errno.h>
 
 #ifdef HAVE_UNISTD_H
@@ -137,7 +138,11 @@ show_backtrace (bool in_signal_handler)
   struct backtrace_state *lbstate;
   struct mystate state = { 0, false, in_signal_handler };
  
-  lbstate = backtrace_create_state (NULL, 1, error_callback, NULL);
+  lbstate = backtrace_create_state (NULL, __gthread_active_p (),
+                                   error_callback, NULL);
+
+  if (lbstate == NULL)
+    return;
 
   if (!BACKTRACE_SUPPORTED || (in_signal_handler && BACKTRACE_USES_MALLOC))
     {