Date: Wed, 19 Feb 2003 13:23:26 +0100 (CET) From: Vaclav Haisman <V.Haisman@sh.cvut.cz> To: freebsd-hackers@freebsd.org Subject: Raising SIGSEGV in SIGSEGV handler makes FreeBSD loop Message-ID: <20030219131316.F68704-100000@logout.sh.cvut.cz>
next in thread | raw e-mail | index | archive | help
Hi, I have been playing with signals handling and I've found one thing where FreeBSD differes from other unix systems that I have access to. This test loops endlessly in FreeBSD but terminates in SunOS 9 and GNU/Linux. It is as test for what happens when a program raises SIGSEGV in SIGSEGV handler. If this touches undefined behaviour then I think the behaviour of the other two systems is saner. Vaclav Haisman #include <signal.h> #include <iostream> int f (int * x); void handler (int, siginfo_t * info, ucontext_t * uap) { std::cerr << "SIGSEGV caught, dumping core" << std::endl; struct sigaction mysig; mysig.sa_handler = SIG_IGN; mysig.sa_sigaction = NULL; mysig.sa_flags = 0; if (sigaction(SIGSEGV, &mysig, NULL) == -1) { std::cerr << "Error in sigaction()" << std::endl; return; } f((int*)NULL); mysig.sa_handler = SIG_DFL; mysig.sa_sigaction = NULL; mysig.sa_flags = 0; if (sigaction(SIGSEGV, &mysig, NULL) == -1) { std::cerr << "Error in sigaction()" << std::endl; return; } } int f (int * x) { int y = *x; return y; } int main () { struct sigaction mysig; mysig.sa_handler = NULL; mysig.sa_sigaction = (void (*)(int, __siginfo *, void *))handler; sigemptyset(&mysig.sa_mask); sigaddset(&mysig.sa_mask, SIGSEGV); mysig.sa_flags = SA_SIGINFO; if (sigaction(SIGSEGV, &mysig, NULL) == -1) { std::cerr << "Error in sigaction()" << std::endl; return 1; } int * x = NULL; int y; y = f(x); return y; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030219131316.F68704-100000>