From: Peter Maydell <peter.maydell@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
qemu-devel@nongnu.org, "Laurent Vivier" <Laurent@vivier.eu>
Subject: Re: [RFC PATCH] linux-user: trap internal SIGABRT's
Date: Fri, 11 Feb 2022 11:46:29 +0000 [thread overview]
Message-ID: <CAFEAcA950Z2i+qemSaiTJ-EhQNmWydUGAkof_7_tQWrk3z3GkA@mail.gmail.com> (raw)
In-Reply-To: <518fd6d9-4b74-d8ad-3e72-360c5ca899f6@linaro.org>
On Wed, 9 Feb 2022 at 22:12, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 2/9/22 22:22, Alex Bennée wrote:
> > linux-user wants to trap all signals in case they are related to the
> > guest. This however results in less than helpful core dumps when the
> > error is internal to QEMU. We can detect when an assert failure is in
> > progress by examining __glib_assert_msg and fall through to
> > cpu_abort() which will pretty print something before restoring the
> > default SIGABRT behaviour and dumping core.
> >
> > Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> > ---
> > linux-user/signal.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/linux-user/signal.c b/linux-user/signal.c
> > index 32854bb375..8ecc1215f7 100644
> > --- a/linux-user/signal.c
> > +++ b/linux-user/signal.c
> > @@ -809,6 +809,8 @@ static inline void rewind_if_in_safe_syscall(void *puc)
> > }
> > }
> >
> > +GLIB_VAR char *__glib_assert_msg;
> > +
> > static void host_signal_handler(int host_sig, siginfo_t *info, void *puc)
> > {
> > CPUArchState *env = thread_cpu->env_ptr;
> > @@ -821,6 +823,10 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc)
> > uintptr_t pc = 0;
> > bool sync_sig = false;
> >
> > + if (__glib_assert_msg) {
> > + cpu_abort(cpu, "internal QEMU error, aborting...");
> > + }
>
> I think we should not be trapping SIGABRT. I think we can preserve all guest behaviour
> wrt SIGABRT by stealing another SIGRTMIN value, and remapping the guest signal number. We
> can produce the correct result for the system by mapping it back to host SIGABRT in
> core_dump_and_abort().
Stealing signal values is awkward, because you don't know what the guest
(either application or libc) might be trying to do with them. I think
we should prefer not to steal them, especially in this case where the
only reason for taking a signal value for our own use is to deal with
a "should never happen anyway" case. We've already had a few bugs/awkwardnesses
with the current level of signal stealing/rearranging we have to do.
thanks
-- PMM
prev parent reply other threads:[~2022-02-11 11:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-09 11:22 [RFC PATCH] linux-user: trap internal SIGABRT's Alex Bennée
2022-02-09 11:38 ` Peter Maydell
2022-02-09 13:12 ` Alex Bennée
2022-02-09 13:27 ` Peter Maydell
2022-02-09 21:56 ` Richard Henderson
2022-02-11 11:46 ` Peter Maydell [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=CAFEAcA950Z2i+qemSaiTJ-EhQNmWydUGAkof_7_tQWrk3z3GkA@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=Laurent@vivier.eu \
--cc=alex.bennee@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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 NNTP newsgroup(s).