Fixed: state->fileline_fn could be 0 in libbacktrace in some cases

This lead, among other things, to crashes of the apps built with TSan
enabled. When the app (or, to be exact, TSan) tried to output a
backtrace of a suspicious event, backtrace_pcinfo() was invoked.

At the end it called state->fileline_fn() which should have been set
before. However, it was not always the case. If debug info was missing
from some library used by the app or it was in a format that
libbacktrace did not understand, libbacktrace did not set
state->fileline_fn. The latter remained 0 and that resulted in a
segfault in backtrace_pcinfo().

Should now be fixed. The fix makes sure that the callback is always
initialized.
This commit is contained in:
Eugene Shatokhin 2014-08-13 13:33:03 +04:00
parent 2c6c76fcaf
commit d268577515
2 changed files with 15 additions and 1 deletions

View file

@ -0,0 +1,11 @@
--- gcc-linaro-4.9-2014.07/libbacktrace/elf.c.orig 2014-03-07 09:07:56.000000000 +0400
+++ gcc-linaro-4.9-2014.07/libbacktrace/elf.c 2014-08-13 12:56:23.285272323 +0400
@@ -925,7 +925,7 @@
int ret;
int found_sym;
int found_dwarf;
- fileline elf_fileline_fn;
+ fileline elf_fileline_fn = elf_nodebug;
struct phdr_data pd;
ret = elf_add (state, descriptor, 0, error_callback, data, &elf_fileline_fn,

View file

@ -200,7 +200,7 @@ Name: gcc
%else
Name: gcc%{branch}
%endif
Release: 2
Release: 3
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
Group: Development/C
Url: http://gcc.gnu.org/
@ -253,6 +253,8 @@ Patch12: gcc-4.8-non-fatal-compare-failure.patch
Patch13: Gcc-4.8.2-arm-thumb2-CASE_VECTOR_SHORTEN_MODE.patch
# Backport from upstream
Patch14: gcc-4.9.1-bug61801.patch
# Fix for fileline_fn callback being NULL in libbacktrace sometimes
Patch15: gcc-4.9.1-libbacktrace-fix-null-callback.patch
BuildRequires: binutils >= 2.20.51.0.2
BuildRequires: dejagnu
@ -2170,6 +2172,7 @@ Static liblsan.
%patch12 -p1 -b .compare~
%patch13 -p1 -b .short
%patch14 -p2 -b .bug61801
%patch15 -p1 -b .libbacktrace
aclocal -I config
autoconf