[PATCH] os: don't ignore failure from dladdr

Julien Cristau jcristau at debian.org
Fri Dec 30 11:41:25 PST 2011


If dladdr returns 0, don't go and use the returned Dl_info, it may
contain garbage.

X.Org bug#44315 <https://bugs.freedesktop.org/show_bug.cgi?id=44315>

Reported-and-tested-by: Cyril Brulebois <kibi at debian.org>
Signed-off-by: Julien Cristau <jcristau at debian.org>
---
 os/backtrace.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/os/backtrace.c b/os/backtrace.c
index 58b4b1f..298bf18 100644
--- a/os/backtrace.c
+++ b/os/backtrace.c
@@ -46,7 +46,11 @@ void xorg_backtrace(void)
     ErrorF("\nBacktrace:\n");
     size = backtrace(array, 64);
     for (i = 0; i < size; i++) {
-	dladdr(array[i], &info);
+	int rc = dladdr(array[i], &info);
+	if (rc == 0) {
+	    ErrorF("%d: ?? [%p]\n", i, array[i]);
+	    continue;
+	}
 	mod = (info.dli_fname && *info.dli_fname) ? info.dli_fname : "(vdso)";
 	if (info.dli_saddr)
 	    ErrorF("%d: %s (%s+0x%lx) [%p]\n", i, mod,
-- 
1.7.7.3



More information about the xorg-devel mailing list