1#!/bin/sh 2 3# Test scenario from: 4# Bug 265889 - sys.kern.basic_signal.trap_signal_test crashes bhyve in i386 VM 5# Test scenario by: Li-Wen Hsu <lwhsu@FreeBSD.org> 6 7cat > /tmp/signal2.c <<EOF 8#include <stdio.h> 9#include <signal.h> 10 11#include <machine/psl.h> 12#define SET_TRACE_FLAG(ucp) (ucp)->uc_mcontext.mc_eflags |= PSL_T 13#define CLR_TRACE_FLAG(ucp) (ucp)->uc_mcontext.mc_eflags &= ~PSL_T 14 15static volatile sig_atomic_t trap_signal_fired = 0; 16 17static void 18trap_sig_handler(int signo __unused, siginfo_t *info __unused, void *_ucp) 19{ 20 ucontext_t *ucp = _ucp; 21 22 if (trap_signal_fired < 9) { 23 SET_TRACE_FLAG(ucp); 24 } else { 25 CLR_TRACE_FLAG(ucp); 26 } 27 trap_signal_fired++; 28} 29 30int main() { 31 struct sigaction sa = { 32 .sa_sigaction = trap_sig_handler, 33 .sa_flags = SA_SIGINFO, 34 }; 35 36 sigemptyset(&sa.sa_mask); 37 sigaction(SIGTRAP, &sa, NULL); 38 39 raise(SIGTRAP); 40 41 printf("test\n"); 42} 43EOF 44cc -o /tmp/signal2 -Wall -Wextra -O0 -m32 /tmp/signal2.c || exit 1 45 46/tmp/signal2; s=$? 47for i in `jot 30`; do 48 /tmp/signal2 & 49done > /dev/null 50wait 51 52rm -f /tmp/signal2 /tmp/signal2.c 53exit $s 54