From owner-freebsd-hackers Wed Feb 19 4:23:27 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DE71A37B401 for ; Wed, 19 Feb 2003 04:23:24 -0800 (PST) Received: from service.sh.cvut.cz (service.sh.cvut.cz [147.32.127.214]) by mx1.FreeBSD.org (Postfix) with ESMTP id BBF1543FA3 for ; Wed, 19 Feb 2003 04:23:23 -0800 (PST) (envelope-from V.Haisman@sh.cvut.cz) Received: from spampd.localdomain (localhost [127.0.0.1]) by service.sh.cvut.cz (Postfix) with ESMTP id E62671B8024 for ; Wed, 19 Feb 2003 13:23:22 +0100 (CET) Received: from logout.sh.cvut.cz (logout.sh.cvut.cz [147.32.127.203]) by service.sh.cvut.cz (Postfix) with ESMTP id 43B541B8067 for ; Wed, 19 Feb 2003 13:23:22 +0100 (CET) Received: from logout (logout [147.32.127.203]) by logout.sh.cvut.cz (Postfix) with ESMTP id 7B5743C314 for ; Wed, 19 Feb 2003 13:23:26 +0100 (CET) Date: Wed, 19 Feb 2003 13:23:26 +0100 (CET) From: Vaclav Haisman To: freebsd-hackers@freebsd.org Subject: Raising SIGSEGV in SIGSEGV handler makes FreeBSD loop Message-ID: <20030219131316.F68704-100000@logout.sh.cvut.cz> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: AMaViS at Silicon Hill X-Spam-Status: No, hits=1.1 required=6.0 tests=CARRIAGE_RETURNS,SPAM_PHRASE_00_01 version=2.44 X-Spam-Level: * Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 #include 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