aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Schrock <steve.schrock@getcruise.com>2024-05-08 14:38:44 +0000
committerDenis Kenzior <denkenz@gmail.com>2024-05-08 10:41:25 -0500
commitcef344ccf05e9ffbdae8830b44c2b5668bfcd38f (patch)
tree41d43abfa1c2632b43d0fa41788283c76f260357
parent15a17439b31a6c76e04d10c354aee423bc663d87 (diff)
downloadofono-master.tar.gz
log: Handle dladdr failureHEADmaster
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. ==36318== Conditional jump or move depends on uninitialised value(s) ==36318== at 0x4A862F8: __printf_buffer (vfprintf-process-arg.c:408) ==36318== by 0x4AA8067: __vsnprintf_internal (vsnprintf.c:96) ==36318== by 0x4B1D62B: __vsyslog_internal (syslog.c:220) ==36318== by 0x4B1DB83: vsyslog (syslog.c:100) ==36318== by 0x407C3F: ofono_error (log.c:92) ==36318== by 0x407FEB: print_backtrace (log.c:201) ==36318== by 0x40816B: signal_handler (log.c:228) ==36318== by 0x580BCE37: ??? (in /usr/libexec/valgrind/memcheck-arm64-linux)
-rw-r--r--src/log.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/log.c b/src/log.c
index a8b4ef10e..fdfad362c 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;
}