Bug#946606: libc-bin: catchsegv does not handle backtraces with parentheses
Package: libc-bin
Version: 2.29-3
Severity: wishlist
Tags: upstream patch
Dear Maintainer,
since upstream commit in 2012 [1] the function __backtrace_symbols_fd
seems to outputs in one of this formats:
program(+<offset>)[<address>]
program(function+<offset>)[<address>]
Therefore the /usr/bin/catchsegv cannot find the backtrace lines
and produces less useful outputs (see below)
There exists an upstream bug about the issue [2].
Attached patch is an attempt to parse the offset instead of the
address, which seems now less important due to ASLR.
Known symbols are currently written by __backtrace_symbols_fd
as such with the offset in relation to the function instead
of the library section.
To get for these also sourcefile and line information
either __backtrace_symbols_fd needs to be changed to
output the library section offset to the backtrace too,
or addr2line (binutils) needs a change to lookup the symbol and
calculate from there, but both would be different issues.
What do you think?
Kind regards,
Bernhard
Current:
Backtrace:
/tmp/tmp.sSrfzsTKpn/3-options-input-fn(+0x175b)[0x557275eb775b]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb)[0x7f4f8194ebbb]
/tmp/tmp.sSrfzsTKpn/3-options-input-fn(+0x11ba)[0x557275eb71ba]
With proposed changes:
Backtrace:
[0x5578ceb0575b] main at /usr/share/doc/libsoxr-dev/examples/3-options-input-fn.c:79 (discriminator 4) /tmp/tmp.sSrfzsTKpn/3-options-input-fn(+0x175b)
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb)[0x7fcf5f243bbb]
[0x5578ceb051ba] _start at ??:? /tmp/tmp.sSrfzsTKpn/3-options-input-fn(+0x11ba)
[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=1d6c3d237d10606121c959b9bd2ae722f79ea899
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=21830
-- System Information:
Debian Release: bullseye/sid
APT prefers testing-debug
APT policy: (500, 'testing-debug'), (500, 'proposed-updates-debug'), (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 5.3.0-2-amd64 (SMP w/12 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages libc-bin depends on:
ii libc6 2.29-3
Versions of packages libc-bin recommends:
ii manpages 5.04-1
libc-bin suggests no packages.
-- no debconf information
>From fca03cd9af5ffaea1e4968fa27a7b28ee80903ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= <bernhardu@mailbox.org>
Date: Wed, 11 Dec 2019 19:56:39 +0100
Subject: Make catchsegv work again after format changed.
https://sourceware.org/bugzilla/show_bug.cgi?id=21830
---
debug/catchsegv.sh | 34 +++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/debug/catchsegv.sh b/debug/catchsegv.sh
index 245c100f..da87122c 100755
--- a/debug/catchsegv.sh
+++ b/debug/catchsegv.sh
@@ -87,18 +87,30 @@ if test -s "$segv_output"; then
sed '/Backtrace/q' "$segv_output"
sed '1,/Backtrace/d' "$segv_output" |
(while read line; do
- line=`echo $line | sed "s@^$prog\\(\\[.*\\)@\1@"`
case "$line" in
- \[*) addr=`echo "$line" | sed 's/^\[\(.*\)\]$/\1/'`
- complete=`addr2line -f -e "$prog" $addr 2>/dev/null`
- if test $? -eq 0; then
- echo "`echo "$complete"|sed 'N;s/\(.*\)\n\(.*\)/\2(\1)/;'`$line"
- else
- echo "$line"
- fi
- ;;
- *) echo "$line"
- ;;
+ *\(*\)\[*\])
+ lib=`echo $line | sed "s@^\(.*\)(\(.*\))\[\(.*\)\]\\$@\1@"`
+ offs=`echo $line | sed "s@^\(.*\)(\(.*\))\[\(.*\)\]\\$@\2@"`
+ addr=`echo $line | sed "s@^\(.*\)(\(.*\))\[\(.*\)\]\\$@\3@"`
+ case "$offs" in
+ +*) case "$prog" in
+ */$lib)
+ lib="$prog"
+ ;;
+ esac
+ complete=`addr2line -p -i -f -e "$lib" $offs 2>/dev/null`
+ if test $? -eq 0; then
+ echo " [$addr] $complete $lib($offs)"
+ else
+ echo " $line"
+ fi
+ ;;
+ *) echo " $line"
+ ;;
+ esac
+ ;;
+ *) echo "$line"
+ ;;
esac
done)
fi
--
2.24.0
Reply to: