Message ID | 20240508143844.42060-1-steve.schrock@getcruise.com (mailing list archive) |
---|---|
State | Accepted |
Commit | cef344ccf05e9ffbdae8830b44c2b5668bfcd38f |
Headers | show |
Series | log: Handle dladdr failure | expand |
Hello: This patch was applied to ofono.git (master) by Denis Kenzior <denkenz@gmail.com>: On Wed, 8 May 2024 14:38:44 +0000 you wrote: > If unit/test-qmimodem-qmi times out while running under valgrind, > valgrind complains about an uninitialized value being printed during > abort signal logging. dladdr fails on the valgrind address > (0x580BCE37 in the example below) but print_backtrace still tries to > access the Dl_info structure which is not initialized. The fix is to > handle the dladdr failure gracefully. > > [...] Here is the summary with links: - log: Handle dladdr failure https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=cef344ccf05e You are awesome, thank you!
diff --git a/src/log.c b/src/log.c index a8b4ef10eaae..fdfad362cfd1 100644 --- a/src/log.c +++ b/src/log.c @@ -171,11 +171,13 @@ static void print_backtrace(unsigned int offset) for (i = offset; i < n_ptrs - 1; i++) { Dl_info info; + const char *fname = "???"; char addr[20], buf[PATH_MAX * 2]; int len, written; char *ptr, *pos; - dladdr(frames[i], &info); + if (dladdr(frames[i], &info)) + fname = info.dli_fname; len = snprintf(addr, sizeof(addr), "%p\n", frames[i]); if (len < 0) @@ -199,7 +201,7 @@ static void print_backtrace(unsigned int offset) if (strcmp(buf, "??") == 0) { ofono_error("#%-2u %p in %s", i - offset, - frames[i], info.dli_fname); + frames[i], fname); continue; }