about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorPaul Pluzhnikov <ppluzhnikov@google.com>2015-08-15 11:42:43 -0700
committerPaul Pluzhnikov <ppluzhnikov@google.com>2015-08-15 11:42:43 -0700
commitd5dff793af80b6534e9fb2e4f0301993bd209a4f (patch)
treec3df534ffb1c966cb96ac71fee5cc0c4f17d3d57 /sysdeps
parent3cda1b6d56335a101ec3de0053248f68f010eee1 (diff)
downloadglibc-d5dff793af80b6534e9fb2e4f0301993bd209a4f.tar.gz
glibc-d5dff793af80b6534e9fb2e4f0301993bd209a4f.tar.xz
glibc-d5dff793af80b6534e9fb2e4f0301993bd209a4f.zip
Fix BZ #18084 -- backtrace (..., 0) dumps core on x86.
Other architectures also had bugs, or did unnecessary work.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/arm/backtrace.c7
-rw-r--r--sysdeps/i386/backtrace.c7
-rw-r--r--sysdeps/m68k/backtrace.c7
-rw-r--r--sysdeps/microblaze/backtrace.c3
-rw-r--r--sysdeps/s390/s390-32/backtrace.c7
-rw-r--r--sysdeps/s390/s390-64/backtrace.c7
-rw-r--r--sysdeps/sparc/backtrace.c2
-rw-r--r--sysdeps/x86_64/backtrace.c7
8 files changed, 34 insertions, 13 deletions
diff --git a/sysdeps/arm/backtrace.c b/sysdeps/arm/backtrace.c
index 7ab487c2fc..5a30c209ff 100644
--- a/sysdeps/arm/backtrace.c
+++ b/sysdeps/arm/backtrace.c
@@ -92,6 +92,10 @@ __backtrace (array, size)
      int size;
 {
   struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+
+  if (size <= 0)
+    return 0;
+
 #ifdef SHARED
   __libc_once_define (static, once);
 
@@ -100,8 +104,7 @@ __backtrace (array, size)
     return 0;
 #endif
 
-  if (size >= 1)
-    unwind_backtrace (backtrace_helper, &arg);
+  unwind_backtrace (backtrace_helper, &arg);
 
   if (arg.cnt > 1 && arg.array[arg.cnt - 1] == NULL)
     --arg.cnt;
diff --git a/sysdeps/i386/backtrace.c b/sysdeps/i386/backtrace.c
index 550234f577..f10ed566dc 100644
--- a/sysdeps/i386/backtrace.c
+++ b/sysdeps/i386/backtrace.c
@@ -114,6 +114,10 @@ __backtrace (array, size)
      int size;
 {
   struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+
+  if (size <= 0)
+    return 0;
+
 #ifdef SHARED
   __libc_once_define (static, once);
 
@@ -122,8 +126,7 @@ __backtrace (array, size)
     return 0;
 #endif
 
-  if (size >= 1)
-    unwind_backtrace (backtrace_helper, &arg);
+  unwind_backtrace (backtrace_helper, &arg);
 
   if (arg.cnt > 1 && arg.array[arg.cnt - 1] == NULL)
     --arg.cnt;
diff --git a/sysdeps/m68k/backtrace.c b/sysdeps/m68k/backtrace.c
index 3114251925..ca7d25929e 100644
--- a/sysdeps/m68k/backtrace.c
+++ b/sysdeps/m68k/backtrace.c
@@ -111,6 +111,10 @@ int
 __backtrace (void **array, int size)
 {
   struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+
+  if (size <= 0)
+    return 0;
+
 #ifdef SHARED
   __libc_once_define (static, once);
 
@@ -119,8 +123,7 @@ __backtrace (void **array, int size)
     return 0;
 #endif
 
-  if (size >= 1)
-    unwind_backtrace (backtrace_helper, &arg);
+  unwind_backtrace (backtrace_helper, &arg);
 
   if (arg.cnt > 1 && arg.array[arg.cnt - 1] == NULL)
     --arg.cnt;
diff --git a/sysdeps/microblaze/backtrace.c b/sysdeps/microblaze/backtrace.c
index 24e827ac39..c043ba7681 100644
--- a/sysdeps/microblaze/backtrace.c
+++ b/sysdeps/microblaze/backtrace.c
@@ -114,6 +114,9 @@ __backtrace (void **array, int size)
   int count;
   int rc = 0;
 
+  if (size <= 0)
+    return 0;
+
   __asm__ __volatile__ ("mfs %0, rpc"
                         : "=r"(pc));
 
diff --git a/sysdeps/s390/s390-32/backtrace.c b/sysdeps/s390/s390-32/backtrace.c
index 73db65275d..4e5e1feee6 100644
--- a/sysdeps/s390/s390-32/backtrace.c
+++ b/sysdeps/s390/s390-32/backtrace.c
@@ -126,6 +126,10 @@ int
 __backtrace (void **array, int size)
 {
   struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+
+  if (size <= 0)
+    return 0;
+
 #ifdef SHARED
   __libc_once_define (static, once);
 
@@ -135,8 +139,7 @@ __backtrace (void **array, int size)
     return __backchain_backtrace (array, size);
 #endif
 
-  if (size >= 1)
-    unwind_backtrace (backtrace_helper, &arg);
+  unwind_backtrace (backtrace_helper, &arg);
 
   return arg.cnt != -1 ? arg.cnt : 0;
 }
diff --git a/sysdeps/s390/s390-64/backtrace.c b/sysdeps/s390/s390-64/backtrace.c
index 08e563e0df..184a73741b 100644
--- a/sysdeps/s390/s390-64/backtrace.c
+++ b/sysdeps/s390/s390-64/backtrace.c
@@ -125,6 +125,10 @@ int
 __backtrace (void **array, int size)
 {
   struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
+
+  if (size <= 0)
+    return 0;
+
 #ifdef SHARED
   __libc_once_define (static, once);
 
@@ -134,8 +138,7 @@ __backtrace (void **array, int size)
     return __backchain_backtrace (array, size);
 #endif
 
-  if (size >= 1)
-    unwind_backtrace (backtrace_helper, &arg);
+  unwind_backtrace (backtrace_helper, &arg);
 
   return arg.cnt != -1 ? arg.cnt : 0;
 }
diff --git a/sysdeps/sparc/backtrace.c b/sysdeps/sparc/backtrace.c
index 754f45bfeb..cb01fd6a07 100644
--- a/sysdeps/sparc/backtrace.c
+++ b/sysdeps/sparc/backtrace.c
@@ -108,7 +108,7 @@ __backtrace (void **array, int size)
   bool use_unwinder;
   int count;
 
-  if (!size)
+  if (size <= 0)
     return 0;
 
   use_unwinder = true;
diff --git a/sysdeps/x86_64/backtrace.c b/sysdeps/x86_64/backtrace.c
index 2a3848d20f..21448c8f1c 100644
--- a/sysdeps/x86_64/backtrace.c
+++ b/sysdeps/x86_64/backtrace.c
@@ -97,6 +97,10 @@ __backtrace (array, size)
      int size;
 {
   struct trace_arg arg = { .array = array, .cfa = 0, .size = size, .cnt = -1 };
+
+  if (size <= 0)
+    return 0;
+
 #ifdef SHARED
   __libc_once_define (static, once);
 
@@ -105,8 +109,7 @@ __backtrace (array, size)
     return 0;
 #endif
 
-  if (size >= 1)
-    unwind_backtrace (backtrace_helper, &arg);
+  unwind_backtrace (backtrace_helper, &arg);
 
   /* _Unwind_Backtrace seems to put NULL address above
      _start.  Fix it up here.  */