From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PULL 04/14] tests/tcg: Test that sigreturn() does not corrupt the signal mask
Date: Fri, 15 Nov 2024 12:58:39 -0800 [thread overview]
Message-ID: <20241115205849.266094-5-richard.henderson@linaro.org> (raw)
In-Reply-To: <20241115205849.266094-1-richard.henderson@linaro.org>
From: Ilya Leoshkevich <iii@linux.ibm.com>
Add a small test to prevent regressions.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-ID: <20241108145237.37377-2-iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tests/tcg/multiarch/sigreturn-sigmask.c | 51 +++++++++++++++++++++++++
tests/tcg/multiarch/Makefile.target | 3 ++
2 files changed, 54 insertions(+)
create mode 100644 tests/tcg/multiarch/sigreturn-sigmask.c
diff --git a/tests/tcg/multiarch/sigreturn-sigmask.c b/tests/tcg/multiarch/sigreturn-sigmask.c
new file mode 100644
index 0000000000..e6cc904898
--- /dev/null
+++ b/tests/tcg/multiarch/sigreturn-sigmask.c
@@ -0,0 +1,51 @@
+/*
+ * Test that sigreturn() does not corrupt the signal mask.
+ * Block SIGUSR2 and handle SIGUSR1.
+ * Then sigwait() SIGUSR2, which relies on it remaining blocked.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <assert.h>
+#include <pthread.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int seen_sig = -1;
+
+static void signal_func(int sig)
+{
+ seen_sig = sig;
+}
+
+static void *thread_func(void *arg)
+{
+ kill(getpid(), SIGUSR2);
+ return NULL;
+}
+
+int main(void)
+{
+ struct sigaction act = {
+ .sa_handler = signal_func,
+ };
+ pthread_t thread;
+ sigset_t set;
+ int sig;
+
+ assert(sigaction(SIGUSR1, &act, NULL) == 0);
+
+ assert(sigemptyset(&set) == 0);
+ assert(sigaddset(&set, SIGUSR2) == 0);
+ assert(sigprocmask(SIG_BLOCK, &set, NULL) == 0);
+
+ kill(getpid(), SIGUSR1);
+ assert(seen_sig == SIGUSR1);
+
+ assert(pthread_create(&thread, NULL, thread_func, NULL) == 0);
+ assert(sigwait(&set, &sig) == 0);
+ assert(sig == SIGUSR2);
+ assert(pthread_join(thread, NULL) == 0);
+
+ return EXIT_SUCCESS;
+}
diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target
index 78b83d5575..18d3cf4ae0 100644
--- a/tests/tcg/multiarch/Makefile.target
+++ b/tests/tcg/multiarch/Makefile.target
@@ -42,6 +42,9 @@ munmap-pthread: LDFLAGS+=-pthread
vma-pthread: CFLAGS+=-pthread
vma-pthread: LDFLAGS+=-pthread
+sigreturn-sigmask: CFLAGS+=-pthread
+sigreturn-sigmask: LDFLAGS+=-pthread
+
# The vma-pthread seems very sensitive on gitlab and we currently
# don't know if its exposing a real bug or the test is flaky.
ifneq ($(GITLAB_CI),)
--
2.43.0
next prev parent reply other threads:[~2024-11-15 21:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 20:58 [PULL 00/14] tcg + linux-user patch queue Richard Henderson
2024-11-15 20:58 ` [PULL 01/14] linux-user: Fix setreuid and setregid to use direct syscalls Richard Henderson
2024-11-15 20:58 ` [PULL 02/14] accel/tcg: Fix user-only probe_access_internal plugin check Richard Henderson
2024-11-15 20:58 ` [PULL 03/14] linux-user: Tolerate CONFIG_LSM_MMAP_MIN_ADDR Richard Henderson
2024-11-15 20:58 ` Richard Henderson [this message]
2024-11-15 20:58 ` [PULL 05/14] target/i386: fix hang when using slow path for ptw_setl Richard Henderson
2024-11-15 20:58 ` [PULL 06/14] cpu: ensure we don't call start_exclusive from cpu_exec Richard Henderson
2024-11-15 20:58 ` [PULL 07/14] linux-user: Honor elf alignment when placing images Richard Henderson
2024-11-15 20:58 ` [PULL 08/14] linux-user: Drop image_info.alignment Richard Henderson
2024-11-15 20:58 ` [PULL 09/14] linux-user/aarch64: Reduce vdso alignment to 4k Richard Henderson
2024-11-15 20:58 ` [PULL 10/14] linux-user/arm: " Richard Henderson
2024-11-15 20:58 ` [PULL 11/14] linux-user/loongarch64: " Richard Henderson
2024-11-15 20:58 ` [PULL 12/14] linux-user/ppc: " Richard Henderson
2024-11-15 20:58 ` [PULL 13/14] linux-user/arm: Select vdso for be8 and be32 modes Richard Henderson
2024-11-15 20:58 ` [PULL 14/14] tcg: Allow top bit of SIMD_DATA_BITS to be set in simd_desc() Richard Henderson
2024-11-16 10:39 ` [PULL 00/14] tcg + linux-user patch queue Peter Maydell
2024-11-16 16:38 ` 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=20241115205849.266094-5-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=iii@linux.ibm.com \
--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).