Commit d6c389cb authored by Bernhard Übelacker's avatar Bernhard Übelacker Committed by Olivier Fourdan

os: Fix instruction pointer written in xorg_backtrace

The address retrieved in "pip.start_ip" is not necessarily the same
address as unw_get_proc_name finds as nearest symbol and returns in "off".
Therefore using "pip.start_ip + off" is not reliable, at least
visible in the binaries from the Debian repository.

Bug-Debian: https://bugs.debian.org/971088Signed-off-by: Bernhard Übelacker's avatarBernhard Übelacker <bernhardu@mailbox.org>
(cherry picked from commit c15dd0ba)
parent c3e4c1a0
Pipeline #222189 passed with stages
in 6 minutes and 35 seconds
...@@ -45,6 +45,7 @@ xorg_backtrace(void) ...@@ -45,6 +45,7 @@ xorg_backtrace(void)
{ {
unw_cursor_t cursor; unw_cursor_t cursor;
unw_context_t context; unw_context_t context;
unw_word_t ip;
unw_word_t off; unw_word_t off;
unw_proc_info_t pip; unw_proc_info_t pip;
int ret, i = 0; int ret, i = 0;
...@@ -88,7 +89,9 @@ xorg_backtrace(void) ...@@ -88,7 +89,9 @@ xorg_backtrace(void)
procname[1] = 0; procname[1] = 0;
} }
if (dladdr((void *)(uintptr_t)(pip.start_ip + off), &dlinfo) && dlinfo.dli_fname && if (unw_get_reg (&cursor, UNW_REG_IP, &ip) < 0)
ip = pip.start_ip + off;
if (dladdr((void *)(uintptr_t)(ip), &dlinfo) && dlinfo.dli_fname &&
*dlinfo.dli_fname) *dlinfo.dli_fname)
filename = dlinfo.dli_fname; filename = dlinfo.dli_fname;
else else
...@@ -96,7 +99,7 @@ xorg_backtrace(void) ...@@ -96,7 +99,7 @@ xorg_backtrace(void)
ErrorFSigSafe("%u: %s (%s%s+0x%x) [%p]\n", i++, filename, procname, ErrorFSigSafe("%u: %s (%s%s+0x%x) [%p]\n", i++, filename, procname,
ret == -UNW_ENOMEM ? "..." : "", (int)off, ret == -UNW_ENOMEM ? "..." : "", (int)off,
(void *)(uintptr_t)(pip.start_ip + off)); (void *)(uintptr_t)(ip));
ret = unw_step(&cursor); ret = unw_step(&cursor);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment