The branch main has been updated by pho:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2aba6e7aaf2fa993b0983457f3055450b1495569

commit 2aba6e7aaf2fa993b0983457f3055450b1495569
Author:     Peter Holm <p...@freebsd.org>
AuthorDate: 2022-08-25 07:47:58 +0000
Commit:     Peter Holm <p...@freebsd.org>
CommitDate: 2022-08-25 07:47:58 +0000

    stress2: Added a regression test
---
 tools/test/stress2/misc/signal2.sh | 53 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/tools/test/stress2/misc/signal2.sh 
b/tools/test/stress2/misc/signal2.sh
new file mode 100755
index 000000000000..2cb0589f1dce
--- /dev/null
+++ b/tools/test/stress2/misc/signal2.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# Test scenario from:
+# Bug 265889 - sys.kern.basic_signal.trap_signal_test crashes bhyve in i386 VM 
+# Test scenario by: Li-Wen Hsu <lw...@freebsd.org>
+
+cat > /tmp/signal2.c <<EOF
+#include <stdio.h>
+#include <signal.h>
+
+#include <machine/psl.h>
+#define    SET_TRACE_FLAG(ucp)    (ucp)->uc_mcontext.mc_eflags |= PSL_T
+#define    CLR_TRACE_FLAG(ucp)    (ucp)->uc_mcontext.mc_eflags &= ~PSL_T
+
+static volatile sig_atomic_t trap_signal_fired = 0;
+
+static void
+trap_sig_handler(int signo __unused, siginfo_t *info __unused, void *_ucp)
+{
+       ucontext_t *ucp = _ucp;
+
+       if (trap_signal_fired < 9) {
+               SET_TRACE_FLAG(ucp);
+       } else {
+               CLR_TRACE_FLAG(ucp);
+       }
+       trap_signal_fired++;
+}
+
+int main() {
+       struct sigaction sa = {
+               .sa_sigaction = trap_sig_handler,
+               .sa_flags = SA_SIGINFO,
+       };
+
+       sigemptyset(&sa.sa_mask);
+       sigaction(SIGTRAP, &sa, NULL);
+
+       raise(SIGTRAP);
+
+       printf("test\n");
+}
+EOF
+cc -o /tmp/signal2 -Wall -Wextra -O0 -m32 /tmp/signal2.c || exit 1
+
+/tmp/signal2; s=$?
+for i in `jot 30`; do
+       /tmp/signal2 &
+done > /dev/null
+wait
+
+rm -f /tmp/signal2 /tmp/signal2.c
+exit $s

Reply via email to