From: Sean Christopherson <seanjc@google.com>
To: Vipin Sharma <vipinsh@google.com>
Cc: David Matlack <dmatlack@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH] KVM: selftests: Gracefully handle empty stack traces
Date: Mon, 26 Sep 2022 20:53:35 +0000 [thread overview]
Message-ID: <YzIRTx/f/bECYvM7@google.com> (raw)
In-Reply-To: <CAHVum0cBvORZo1k0p2MQVZQ8tLddpjOmDrmfV19zuTLUYMjrpA@mail.gmail.com>
On Mon, Sep 26, 2022, Vipin Sharma wrote:
> On Thu, Sep 22, 2022 at 4:17 PM David Matlack <dmatlack@google.com> wrote:
> >
> > Bail out of test_dump_stack() if the stack trace is empty rather than
> > invoking addr2line with zero addresses. The problem with the latter is
> > that addr2line will block waiting for addresses to be passed in via
> > stdin, e.g. if running a selftest from an interactive terminal.
How does this bug occur? Does backtrace() get inlined?
> > Opportunistically fix up the comment that mentions skipping 3 frames
> > since only 2 are skipped in the code.
> >
> > Cc: Vipin Sharma <vipinsh@google.com>
> > Cc: Sean Christopherson <seanjc@google.com>
> > Signed-off-by: David Matlack <dmatlack@google.com>
> > ---
> > tools/testing/selftests/kvm/lib/assert.c | 12 +++++++++---
> > 1 file changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/testing/selftests/kvm/lib/assert.c b/tools/testing/selftests/kvm/lib/assert.c
> > index 71ade6100fd3..c1ce54a41eca 100644
> > --- a/tools/testing/selftests/kvm/lib/assert.c
> > +++ b/tools/testing/selftests/kvm/lib/assert.c
> > @@ -42,12 +42,18 @@ static void test_dump_stack(void)
> > c = &cmd[0];
> > c += sprintf(c, "%s", addr2line);
> > /*
> > - * Skip the first 3 frames: backtrace, test_dump_stack, and
> > - * test_assert. We hope that backtrace isn't inlined and the other two
> > - * we've declared noinline.
> > + * Skip the first 2 frames, which should be test_dump_stack() and
> > + * test_assert(); both of which are declared noinline. Bail if the
> > + * resulting stack trace would be empty. Otherwise, addr2line will block
> > + * waiting for addresses to be passed in via stdin.
> > */
> > + if (n <= 2) {
> > + fputs(" (stack trace empty)\n", stderr);
> > + return;
> > + }
>
> Shouldn't this condition be put immediately after
> n = backtrace(stack,n)
Agreed, that would be more intuitive.
next prev parent reply other threads:[~2022-09-26 20:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-22 23:17 [PATCH] KVM: selftests: Gracefully handle empty stack traces David Matlack
2022-09-26 20:41 ` Vipin Sharma
2022-09-26 20:53 ` Sean Christopherson [this message]
2022-09-26 21:47 ` David Matlack
2022-09-27 13:51 ` Paolo Bonzini
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=YzIRTx/f/bECYvM7@google.com \
--to=seanjc@google.com \
--cc=dmatlack@google.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=vipinsh@google.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