All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Anthony Liguori <aliguori@amazon.com>,
	Andreas Faerber <afaerber@suse.de>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/3] qtest: kill QEMU process on g_assert() failure
Date: Tue, 18 Feb 2014 15:52:21 +0100	[thread overview]
Message-ID: <87ob2479sq.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <20140218143839.GA15348@stefanha-thinkpad.redhat.com> (Stefan Hajnoczi's message of "Tue, 18 Feb 2014 15:38:39 +0100")

Stefan Hajnoczi <stefanha@gmail.com> writes:

> On Tue, Feb 18, 2014 at 11:02:52AM +0100, Markus Armbruster wrote:
>> Markus Armbruster <armbru@redhat.com> writes:
>> 
>> > Stefan Hajnoczi <stefanha@redhat.com> writes:
>> >
>> >> The QEMU process stays running if the test case fails.  This patch fixes
>> >> the leak by installing a SIGABRT signal handler which invokes
>> >> qtest_end().
>> >>
>> >> In order to make that work for assertion failures during qtest_init(),
>> >> we need to initialize QTestState fields including file descriptors and
>> >> pids carefully.  qtest_quit() is then safe to call even during
>> >> qtest_init().
>> >>
>> >> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>> >> ---
>> >>  tests/libqtest.c | 29 ++++++++++++++++++++++++++---
>> >>  1 file changed, 26 insertions(+), 3 deletions(-)
>> >>
>> >> diff --git a/tests/libqtest.c b/tests/libqtest.c
>> >> index 8b2b2d7..09a0481 100644
>> >> --- a/tests/libqtest.c
>> >> +++ b/tests/libqtest.c
>> >> @@ -44,6 +44,7 @@ struct QTestState
>> >>      bool irq_level[MAX_IRQ];
>> >>      GString *rx;
>> >>      pid_t qemu_pid;  /* our child QEMU process */
>> >> +    struct sigaction sigact_old; /* restored on exit */
>> >>  };
>> >>  
>> >>  #define g_assert_no_errno(ret) do { \
>> >> @@ -88,6 +89,11 @@ static int socket_accept(int sock)
>> >>      return ret;
>> >>  }
>> >>  
>> >> +static void sigabrt_handler(int signo)
>> >> +{
>> >> +    qtest_end();
>> 
>> Don't you have to re-raise SIGABRT here, to actually terminate the
>> process?
>
> No.  POSIX says:
>
>   RETURN VALUE
>        The abort() function shall not return.
>
> (BTW the way to avoid that is using longjmp.)
>
> The Linux man page is more explicit:
>
>   If  the  SIGABRT  signal  is ignored, or caught by a handler that returns,
>   the abort() function will still terminate the process.  It does this by
>   restoring the default disposition for  SIGABRT and then raising the signal
>   for a second time.

Learn something new :)  Thanks!

      reply	other threads:[~2014-02-18 14:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-17 15:44 [Qemu-devel] [PATCH 0/3] qtest: avoid pidfile and QEMU process leaks Stefan Hajnoczi
2014-02-17 15:44 ` [Qemu-devel] [PATCH 1/3] qtest: drop unused child_pid field Stefan Hajnoczi
2014-02-17 15:44 ` [Qemu-devel] [PATCH 2/3] qtest: make QEMU our direct child process Stefan Hajnoczi
2014-02-17 16:44   ` Markus Armbruster
2014-02-18  9:00     ` Stefan Hajnoczi
2014-02-18  9:53       ` Markus Armbruster
2014-02-17 15:44 ` [Qemu-devel] [PATCH 3/3] qtest: kill QEMU process on g_assert() failure Stefan Hajnoczi
2014-02-17 16:16   ` Paolo Bonzini
2014-02-17 17:00     ` Markus Armbruster
2014-02-18  9:05       ` Stefan Hajnoczi
2014-02-18 10:05         ` Markus Armbruster
2014-02-18 10:23           ` Paolo Bonzini
2014-02-18 10:43             ` Markus Armbruster
2014-02-18 14:38               ` Stefan Hajnoczi
2014-02-18 10:07         ` Paolo Bonzini
2014-02-18 10:17           ` Daniel P. Berrange
2014-02-18 10:23             ` Paolo Bonzini
2014-02-17 16:49   ` Markus Armbruster
2014-02-17 16:56     ` Paolo Bonzini
2014-02-18  9:17     ` Stefan Hajnoczi
2014-02-18  9:55       ` Markus Armbruster
2014-02-18 14:44         ` Stefan Hajnoczi
2014-02-18 14:56       ` Peter Maydell
2014-02-18 10:02     ` Markus Armbruster
2014-02-18 14:38       ` Stefan Hajnoczi
2014-02-18 14:52         ` Markus Armbruster [this message]

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=87ob2479sq.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=afaerber@suse.de \
    --cc=aliguori@amazon.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.