This is the mail archive of the
mailing list for the elfutils project.
Re: [PATCH elfutils 2/2] [tests] parse inode in /proc/pid/maps correctly in run-backtrace-data.sh
On Tue, Jan 29, 2019 at 09:23:39PM +0000, Yonghong Song wrote:
> On 1/29/19 12:50 PM, Mark Wielaard wrote:
> > On Fri, Jan 25, 2019 at 01:20:09PM -0800, Yonghong Song wrote:
> >> 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 00000000 00:50 10224326387095067468 /home/...
> > I have a bit of trouble replicating this (with a simple sscanf).
> > How exactly does it fail?
> The error message looks like:
> -bash-4.4$ cat run-backtrace-data.sh.log
> maps_lookup: Assertion `errno == 0' failed.
> line 84: 3123578 Aborted (core dumped)
> $VALGRIND_CMD "$@"
> data: no main
> The reason is errno is ERANGE.
Aha. Thanks. That is what I get for not testing against the actual
testcase. I wasn't checking errno. But that certainly explains the
issue. The %*x would parse the number as an hex number, causing the
number to be so big that it generated an ERANGE (also it would
accept some things that it shouldn't). But with %*u it uses base-10
encoding, so the number doesn't get too big.
So your fix is correct.
But the testcase is also slightly wrong.
It really shouldn't check errno if the function didn't fail.
There is no guarantee that it will be zero.
> "%u" works as well. Let me submit another patch for this.