Package: xserver-xorg-core
Version: 2:1.20.8-2
Severity: wishlist
Dear Maintainer,
in the past I was trying to make sense of some backtraces written
by Xorg, but failed, e.g. in #969739.
I did now some debugging and found that in function xorg_backtrace
the function begin retrieved by unw_get_proc_info in "pip.start_ip"
cannot always be used for calculations with "off".
This is because this "off" offset is calculated in unw_get_proc_name
from the nearest symbol, which does not necessarily match pip.start_ip.
Attached patch separately retrieves the instruction pointer by unw_get_reg
and uses that value for the output. A short in gdb wrote with this patch
applied the same addresses as the bt command.
What do you think?
Kind regards,
Bernhard
-- Package-specific info:
/etc/X11/X does not exist.
/etc/X11/X is not a symlink.
/etc/X11/X is not executable.
-- 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.8.0-2-amd64 (SMP w/4 CPU threads)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages xserver-xorg-core depends on:
ii keyboard-configuration 1.196
ii libaudit1 1:2.8.5-3+b1
ii libbsd0 0.10.0-1
ii libc6 2.31-3
ii libdbus-1-3 1.12.20-1
ii libdrm2 2.4.102-1
ii libegl1 1.3.2-1
ii libepoxy0 1.5.4-1
ii libgbm1 20.1.8-1
ii libgcrypt20 1.8.6-2
ii libgl1 1.3.2-1
ii libpciaccess0 0.16-1
ii libpixman-1-0 0.36.0-1
ii libselinux1 3.1-2
ii libsystemd0 246.6-1
ii libudev1246.6-1
ii libunwind8 1.3.2-2
ii libxau6 1:1.0.8-1+b2
ii libxdmcp6 1:1.1.2-3
ii libxfont2 1:2.0.3-1
ii libxshmfence1 1.3-1
ii udev246.6-1
ii xserver-common 2:1.20.8-2
Versions of packages xserver-xorg-core recommends:
ii libgl1-mesa-dri 20.1.8-1
ii libpam-systemd 246.6-1
>From 2c1cd5ebf5e9281c2e02b9fcaf4430b314a44909 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?=
Date: Sun, 27 Sep 2020 18:03:48 +0200
Subject: Do not mix the function begin address from unw_get_proc_info and the
offset from unw_get_proc_name.
---
os/backtrace.c | 7 +--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/os/backtrace.c b/os/backtrace.c
index 619bf14..2aad0e3 100644
--- a/os/backtrace.c
+++ b/os/backtrace.c
@@ -45,6 +45,7 @@ xorg_backtrace(void)
{
unw_cursor_t cursor;
unw_context_t context;
+unw_word_t ip;
unw_word_t off;
unw_proc_info_t pip;
int ret, i = 0;
@@ -88,7 +89,9 @@ xorg_backtrace(void)
procname[1] = 0;
}
-if (dladdr((void *)(uintptr_t)(pip.start_ip + off), ) && dlinfo.dli_fname &&
+if (unw_get_reg (, UNW_REG_IP, ) < 0)
+ ip = pip.start_ip + off;
+if (dladdr((void *)(uintptr_t)(ip), ) && dlinfo.dli_fname &&
*dlinfo.dli_fname)
filename = dlinfo.dli_fname;
else
@@ -96,7 +99,7 @@ xorg_backtrace(void)
ErrorFSigSafe("%u: %s (%s%s+0x%x) [%p]\n", i++, filename, procname,
ret == -UNW_ENOMEM ? "..." : "", (int)off,
-(void *)(uintptr_t)(pip.start_ip + off));
+(void *)(uintptr_t)(ip));
ret = unw_step();
if (ret < 0)
--
2.28.0
# Bullseye/testing amd64 qemu VM 2020-09-25
apt update
apt dist-upgrade
apt install ccache cmake make g++-multilib gdb pkg-config coreutils
python3-pexpect manpages-dev git ninja-build capnproto libcapnp-dev
git clone https://github.com/mozilla/rr.git
mkdir obj && cd obj
cmake ../rr
make -j$(nproc)
apt install systemd-coredump psmisc mc fakeroot gdb xserver-xorg xterm openbox
xserver-xorg-core-dbgsym libdbus-1-3-dbgsym libunwind8-dbgsym
apt build-dep xserver-xorg-core
echo 1 > /proc/sys/kernel/perf_event_paranoid
mkdir /home/benutzer/source/xserver-xorg-core/orig -p
cd/home/benutzer/source/xserver-xorg-core/orig
apt source xserver-xorg-core
cd xorg-server-1.20.8
mkdir x/x/x/x/x/x/x/x -p
cd
mkdir /home/benutzer/source/libunwind8/orig -p
cd/home/benutzer/source/libunwind8/orig
apt source libunwind8
cd
# apt install pstack
wget
https://snapshot.debian.org/archive/debian/20170317T095121Z/pool/main/p/pstack/pstack_1.3.1-1%2Bb1_amd64.deb
dpkg -i pstack_1.3.1-1+b1_amd64.deb
root@debian:~# pstack 37009
37009: mc -e ./os/backtrace.c
(No symbols found)
crawl: Input/output error
Error tracing through process 37009
0x7f2b9826e926: root@debian:~#
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=950168
/home/benutzer/obj/bin/rr