diff options
author | Paul Pluzhnikov <ppluzhnikov@google.com> | 2015-08-15 11:42:43 -0700 |
---|---|---|
committer | Paul Pluzhnikov <ppluzhnikov@google.com> | 2015-08-15 11:42:43 -0700 |
commit | d5dff793af80b6534e9fb2e4f0301993bd209a4f (patch) | |
tree | c3df534ffb1c966cb96ac71fee5cc0c4f17d3d57 | |
parent | 3cda1b6d56335a101ec3de0053248f68f010eee1 (diff) | |
download | glibc-d5dff793af80b6534e9fb2e4f0301993bd209a4f.tar.gz |
Fix BZ #18084 -- backtrace (..., 0) dumps core on x86.
Other architectures also had bugs, or did unnecessary work.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | debug/tst-backtrace2.c | 6 | ||||
-rw-r--r-- | sysdeps/arm/backtrace.c | 7 | ||||
-rw-r--r-- | sysdeps/i386/backtrace.c | 7 | ||||
-rw-r--r-- | sysdeps/m68k/backtrace.c | 7 | ||||
-rw-r--r-- | sysdeps/microblaze/backtrace.c | 3 | ||||
-rw-r--r-- | sysdeps/s390/s390-32/backtrace.c | 7 | ||||
-rw-r--r-- | sysdeps/s390/s390-64/backtrace.c | 7 | ||||
-rw-r--r-- | sysdeps/sparc/backtrace.c | 2 | ||||
-rw-r--r-- | sysdeps/x86_64/backtrace.c | 7 |
11 files changed, 57 insertions, 16 deletions
@@ -1,3 +1,16 @@ +2015-08-15 Paul Pluzhnikov <ppluzhnikov@google.com> + + [BZ #18084] + * debug/tst-backtrace2.c (do_test): Add test for BZ #18084. + * sysdeps/arm/backtrace.c (__backtrace): Handle size <= 0. + * sysdeps/i386/backtrace.c (__backtrace): Likewise. + * sysdeps/m68k/backtrace.c (__backtrace): Likewise. + * sysdeps/microblaze/backtrace.c (__backtrace): Likewise. + * sysdeps/s390/s390-32/backtrace.c (__backtrace): Likewise. + * sysdeps/s390/s390-64/backtrace.c (__backtrace): Likewise. + * sysdeps/sparc/backtrace.c (__backtrace): Likewise. + * sysdeps/x86_64/backtrace.c (__backtrace): Likewise. + 2015-08-15 Zack Weinberg <zackw@panix.com> [BZ #18795] @@ -9,9 +9,10 @@ Version 2.23 * The following bugs are resolved with this release: - 16517, 16519, 16520, 16734, 17905, 18086, 18265, 18480, 18525, 18618, - 18647, 18661, 18674, 18778, 18781, 18787, 18789, 18790, 18795, 18820, - 18824. + 16517, 16519, 16520, 16734, 17905, 18084, 18086, 18265, 18480, 18525, + 18618, 18647, 18661, 18674, 18778, 18781, 18787, 18789, 18790, 18795, + 18820, 18824. + Version 2.22 diff --git a/debug/tst-backtrace2.c b/debug/tst-backtrace2.c index 846ca35555..396d743a53 100644 --- a/debug/tst-backtrace2.c +++ b/debug/tst-backtrace2.c @@ -94,6 +94,12 @@ fn3 (void) NO_INLINE static int do_test (void) { + /* Test BZ #18084. */ + void *buffer[1]; + + if (backtrace (buffer, 0) != 0) + FAIL (); + fn3 (); return ret; } 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. */ |