[PATCH elfutils 0/2] fix two /proc/pid/maps inode parsing issues
The inode number in /proc/pid/maps has type "unsigned long". The current parsing in libdwfl/linux-proc-maps.c and tests/backtrace-data.c is not correct and it triggered the following four test failures in one x64 box. FAIL: dwfl-bug-fd-leak FAIL: run-backtrace-data.sh FAIL: run-backtrace-dwarf.sh FAIL: vdsosyms The offending map entry 7f269223d000-7f269226b000 r-xp 00:50 10224326387095067468 /home/... has an inode number beyond the valid range of type "long". This patch set fixed the problem in libdwfl and tests respectively. Yonghong Song (2): [libdwfl] parse inode in /proc/pid/maps correctly [tests] parse inode in /proc/pid/maps correctly in run-backtrace-data.sh libdwfl/linux-proc-maps.c | 2 +- tests/backtrace-data.c| 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.17.1
[PATCH elfutils 2/2] [tests] parse inode in /proc/pid/maps correctly in run-backtrace-data.sh
The backtrace-data.c parsed the inode in /proc/pid/maps with format "%*x". This caused failure if inode is big. For example, 7f269223d000-7f269226b000 r-xp 00:50 10224326387095067468 /home/... The correct format should be "%*lu" to reflect inode "unsigned long" type. But that caused the following compilation error. acktrace-data.c: In function ‘maps_lookup’: backtrace-data.c:109:22: error: use of assignment suppression and length modifier together in gnu_scanf format [-Werror=format=] i = fscanf (f, "%lx-%lx %*s %lx %*x:%*x %*lu", &start, &end, &offset); Fix the test with inode format string "%*s" then. Signed-off-by: Yonghong Song --- tests/backtrace-data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c index 3a91c664..85ae9729 100644 --- a/tests/backtrace-data.c +++ b/tests/backtrace-data.c @@ -106,7 +106,7 @@ maps_lookup (pid_t pid, Dwarf_Addr addr, GElf_Addr *basep) { // 37e3c22000-37e3c23000 rw-p 00022000 00:11 49532 /lib64/ld-2.14.90.so */ unsigned long start, end, offset; - i = fscanf (f, "%lx-%lx %*s %lx %*x:%*x %*x", &start, &end, &offset); + i = fscanf (f, "%lx-%lx %*s %lx %*x:%*x %*s", &start, &end, &offset); assert (errno == 0); if (i != 3) break; -- 2.17.1
[PATCH elfutils 1/2] [libdwfl] parse inode in /proc/pid/maps correctly
The inode number in /proc/pid/maps is displayed as "unsigned long" type. In one of our x64 system, we have inode number exceeding valid "long" type range, which caused the following test failure: FAIL: dwfl-bug-fd-leak FAIL: run-backtrace-dwarf.sh FAIL: vdsosyms The offending map entry: 7f269246b000-7f269246c000 rw-p 0002e000 00:50 10224326387095067468 /home/... This patch changed sscanf inode number type from PRIi64 to PRIu64 and fixed the problem. Signed-off-by: Yonghong Song --- libdwfl/linux-proc-maps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c index c4438c0f..719cba68 100644 --- a/libdwfl/linux-proc-maps.c +++ b/libdwfl/linux-proc-maps.c @@ -217,7 +217,7 @@ proc_maps_report (Dwfl *dwfl, FILE *f, GElf_Addr sysinfo_ehdr, pid_t pid) uint64_t ino; int nread = -1; if (sscanf (line, "%" PRIx64 "-%" PRIx64 " %*s %" PRIx64 - " %x:%x %" PRIi64 " %n", + " %x:%x %" PRIu64 " %n", &start, &end, &offset, &dmajor, &dminor, &ino, &nread) < 6 || nread <= 0) { -- 2.17.1