diff options
author | Bernhard Übelacker <bernhardu@mailbox.org> | 2020-09-27 18:03:48 +0200 |
---|---|---|
committer | Olivier Fourdan <fourdan@gmail.com> | 2020-11-02 12:57:55 +0000 |
commit | d6c389cb87b220f7005cebf483708267b5f4a1c3 (patch) | |
tree | 31a9e922b4b5f9f142b8d3657643958c99d96d07 /os | |
parent | c3e4c1a0fd5d4d6015e9e6317b758018317e56d1 (diff) |
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/971088
Signed-off-by: Bernhard Übelacker <bernhardu@mailbox.org>
(cherry picked from commit c15dd0ba4893f79f7181e783cb1ba404edca917a)
Diffstat (limited to 'os')
-rw-r--r-- | os/backtrace.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/os/backtrace.c b/os/backtrace.c index 619bf145e..2aad0e38a 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) && 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) 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(&cursor); if (ret < 0) |