public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Yonghong Song <yhs@fb.com>
Cc: "elfutils-devel@sourceware.org" <elfutils-devel@sourceware.org>,
	Alexei Starovoitov <ast@fb.com>
Subject: Re: [PATCH elfutils 2/2] [tests] parse inode in /proc/pid/maps correctly in run-backtrace-data.sh
Date: Thu, 31 Jan 2019 21:14:00 -0000	[thread overview]
Message-ID: <20190131211432.GP9378@wildebeest.org> (raw)
In-Reply-To: <7285f5c4-9477-b17e-2909-7b07cf2dceda@fb.com>

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
> backtrace-data: 
> /home/engshare/elfutils/0.174/src/elfutils-0.174/tests/backtrace-data.c:110: 
> maps_lookup: Assertion `errno == 0' failed.
> /home/engshare/elfutils/0.174/src/elfutils-0.174/tests/test-subr.sh: 
> line 84: 3123578 Aborted                 (core dumped) 
> LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" 
> $VALGRIND_CMD "$@"
> data: no main
> -bash-4.4$
> 
> 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.

Thanks,

Mark

  reply	other threads:[~2019-01-31 21:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-25 21:20 [PATCH elfutils 0/2] fix two /proc/pid/maps inode parsing issues Yonghong Song
2019-01-25 21:20 ` [PATCH elfutils 2/2] [tests] parse inode in /proc/pid/maps correctly in run-backtrace-data.sh Yonghong Song
2019-01-29 20:50   ` Mark Wielaard
2019-01-29 21:23     ` Yonghong Song
2019-01-31 21:14       ` Mark Wielaard [this message]
2019-01-31 22:26         ` Mark Wielaard
2019-01-25 21:20 ` [PATCH elfutils 1/2] [libdwfl] parse inode in /proc/pid/maps correctly Yonghong Song
2019-01-29 20:10   ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190131211432.GP9378@wildebeest.org \
    --to=mark@klomp.org \
    --cc=ast@fb.com \
    --cc=elfutils-devel@sourceware.org \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).