qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, "Ilya Leoshkevich" <iii@linux.ibm.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: [PULL 1/5] linux-user: Clean up when exiting due to a signal
Date: Mon, 16 Jan 2023 12:36:33 -1000	[thread overview]
Message-ID: <20230116223637.3512814-2-richard.henderson@linaro.org> (raw)
In-Reply-To: <20230116223637.3512814-1-richard.henderson@linaro.org>

From: Ilya Leoshkevich <iii@linux.ibm.com>

When exiting due to an exit() syscall, qemu-user calls
preexit_cleanup(), but this is currently not the case when exiting due
to a signal. This leads to various buffers not being flushed (e.g.,
for gprof, for gcov, and for the upcoming perf support).

Add the missing call.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230112152013.125680-2-iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/signal.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 61c6fa3fcf..098f3a787d 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -695,7 +695,7 @@ void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
 
 /* abort execution with signal */
 static G_NORETURN
-void dump_core_and_abort(int target_sig)
+void dump_core_and_abort(CPUArchState *cpu_env, int target_sig)
 {
     CPUState *cpu = thread_cpu;
     CPUArchState *env = cpu->env_ptr;
@@ -724,6 +724,8 @@ void dump_core_and_abort(int target_sig)
             target_sig, strsignal(host_sig), "core dumped" );
     }
 
+    preexit_cleanup(cpu_env, 128 + target_sig);
+
     /* The proper exit code for dying from an uncaught signal is
      * -<signal>.  The kernel doesn't allow exit() or _exit() to pass
      * a negative value.  To get the proper exit code we need to
@@ -1058,12 +1060,12 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig,
                    sig != TARGET_SIGURG &&
                    sig != TARGET_SIGWINCH &&
                    sig != TARGET_SIGCONT) {
-            dump_core_and_abort(sig);
+            dump_core_and_abort(cpu_env, sig);
         }
     } else if (handler == TARGET_SIG_IGN) {
         /* ignore sig */
     } else if (handler == TARGET_SIG_ERR) {
-        dump_core_and_abort(sig);
+        dump_core_and_abort(cpu_env, sig);
     } else {
         /* compute the blocked signals during the handler execution */
         sigset_t *blocked_set;
-- 
2.34.1



  reply	other threads:[~2023-01-16 22:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 22:36 [PULL 0/5] tcg patch queue Richard Henderson
2023-01-16 22:36 ` Richard Henderson [this message]
2023-01-16 22:36 ` [PULL 2/5] accel/tcg: Add debuginfo support Richard Henderson
2023-01-16 22:36 ` [PULL 3/5] tcg: add perfmap and jitdump Richard Henderson
2023-06-02 17:21   ` Peter Maydell
2023-06-03 20:35     ` Ilya Leoshkevich
2023-06-29 11:31   ` Philippe Mathieu-Daudé
2023-06-29 12:59     ` Richard Henderson
2023-06-30 12:39       ` Ilya Leoshkevich
2023-06-30 13:24         ` Richard Henderson
2023-12-07  9:51           ` Philippe Mathieu-Daudé
2025-05-19 15:07   ` Peter Maydell
2023-01-16 22:36 ` [PULL 4/5] util/bufferiszero: Use __attribute__((target)) for avx2/avx512 Richard Henderson
2023-01-16 22:36 ` [PULL 5/5] accel/tcg: Split out cpu_exec_{setjmp,loop} Richard Henderson
2023-01-17 15:47 ` [PULL 0/5] tcg patch queue Peter Maydell
2023-01-20  9:41 ` Thomas Huth
2023-01-20 10:50   ` Alex Bennée
2023-01-20 10:53   ` Ilya Leoshkevich
2023-01-20 12:51     ` Thomas Huth
2023-01-20 16:49       ` Alex Bennée
2023-01-21  6:07   ` Richard Henderson

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=20230116223637.3512814-2-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=iii@linux.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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).