From owner-freebsd-ppc@FreeBSD.ORG Thu Oct 17 00:00:01 2013 Return-Path: Delivered-To: freebsd-ppc@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 52EB1890 for ; Thu, 17 Oct 2013 00:00:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2EE7823AC for ; Thu, 17 Oct 2013 00:00:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r9H001vk036394 for ; Thu, 17 Oct 2013 00:00:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r9H000ew036347; Thu, 17 Oct 2013 00:00:00 GMT (envelope-from gnats) Resent-Date: Thu, 17 Oct 2013 00:00:00 GMT Resent-Message-Id: <201310170000.r9H000ew036347@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ppc@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Julio Merino Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id B91C12D2 for ; Wed, 16 Oct 2013 23:51:04 +0000 (UTC) (envelope-from julio@meroh.net) Received: from cdptpa-oedge-vip.email.rr.com (cdptpa-outbound-snat.email.rr.com [107.14.166.225]) by mx1.freebsd.org (Postfix) with ESMTP id 799E02361 for ; Wed, 16 Oct 2013 23:51:04 +0000 (UTC) Received: from [108.176.158.82] ([108.176.158.82:65326] helo=portal.meroh.net) by cdptpa-oedge01 (envelope-from ) (ecelerity 3.5.0.35861 r(Momo-dev:tip)) with ESMTP id 01/7B-02506-0662F525; Wed, 16 Oct 2013 23:50:57 +0000 Received: from mastodon.meroh.net (mastodon.meroh.net [192.168.1.12]) by portal.meroh.net (Postfix) with ESMTP id 62C81EFE67 for ; Wed, 16 Oct 2013 19:50:47 -0400 (EDT) Received: from mastodon.meroh.net (localhost [127.0.0.1]) by mastodon.meroh.net (8.14.7/8.14.7) with ESMTP id r9GNnDMf012498 for ; Wed, 16 Oct 2013 19:49:13 -0400 (EDT) (envelope-from jmmv@mastodon.meroh.net) Received: (from jmmv@localhost) by mastodon.meroh.net (8.14.7/8.14.7/Submit) id r9GNnDud012497; Wed, 16 Oct 2013 19:49:13 -0400 (EDT) (envelope-from jmmv) Message-Id: <201310162349.r9GNnDud012497@mastodon.meroh.net> Date: Wed, 16 Oct 2013 19:49:13 -0400 (EDT) From: Julio Merino To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.114 Subject: powerpc/183040: Nested signal handling is broken X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Julio Merino List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Oct 2013 00:00:01 -0000 >Number: 183040 >Category: powerpc >Synopsis: Nested signal handling is broken >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ppc >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Oct 17 00:00:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Julio Merino >Release: FreeBSD 11.0-CURRENT powerpc >Organization: >Environment: System: FreeBSD mastodon.meroh.net 11.0-CURRENT FreeBSD 11.0-CURRENT #9 r256450M: Mon Oct 14 16:35:08 EDT 2013 jmmv@mastodon.meroh.net:/usr/obj/usr/src/sys/GENERIC64 powerpc Also affects FreeBSD 10.0 alphas. >Description: When programming a given signal twice in a nested manner, the unprogramming of the top-most signal handler does not properly restore the previous (non-default handler). In other words: program signal X program signal X deliver signal X to self -- custom handler runs unprogram signal X deliver signal X to self -- default handler runs or not delivered unprogram signal X Interestingly, things seem to work well for X = SIGTERM but not for X = SIGHUP nor X = SIGINT. I have not tested other signals. I have encountered this bug while running the kyua test suite on a powerpc64 machine (specifics detailed above) and noticing a couple of tests fail, which work well in other operating systems and in amd64. The test case below is derived form the code in kyua. Here is the output of the test program on an amd64 machine, which to my knowledge is working properly: SIGNAL 1 Programming at level 1 Programming at level 0 Signal 1 caught correctly Unprogramming at level 0 Signal 1 caught correctly Unprogramming at level 1 SIGNAL 2 Programming at level 1 Programming at level 0 Signal 2 caught correctly Unprogramming at level 0 Signal 2 caught correctly Unprogramming at level 1 SIGNAL 15 Programming at level 1 Programming at level 0 Signal 15 caught correctly Unprogramming at level 0 Signal 15 caught correctly Unprogramming at level 1 The same test program yields this on powerpc64: SIGNAL 1 Programming at level 1 Programming at level 0 Signal 1 caught correctly Unprogramming at level 0 a.out: Signal 1 not caught >How-To-Repeat: Build and run this test program: ----- #include #include #include #include #include #include static bool caught = false; static void handler(const int signo) { caught = true; } static void do_it(const int signo, const int level) { struct sigaction sa, old_sa; printf("Programming at level %d\n", level); sa.sa_handler = handler; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESTART; if (sigaction(signo, &sa, &old_sa) == -1) err(EXIT_FAILURE, "sigaction program failed"); if (level > 0) do_it(signo, level - 1); caught = false; kill(getpid(), signo); if (caught) printf("Signal %d caught correctly\n", signo); else errx(EXIT_FAILURE, "Signal %d not caught\n", signo); if (sigaction(signo, &old_sa, NULL) == -1) err(EXIT_FAILURE, "sigaction unprogram failed"); printf("Unprogramming at level %d\n", level); } static void try_one_signal(const int signo, const int level) { printf("SIGNAL %d\n", signo); do_it(signo, level); printf("\n"); } int main(void) { try_one_signal(SIGHUP, 1); try_one_signal(SIGINT, 1); try_one_signal(SIGTERM, 1); return EXIT_SUCCESS; } ----- >Fix: >Release-Note: >Audit-Trail: >Unformatted: