From owner-freebsd-current Wed Mar 12 8:25:49 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 26FC637B401; Wed, 12 Mar 2003 08:25:47 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id A105143FAF; Wed, 12 Mar 2003 08:25:45 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id DAA04937; Thu, 13 Mar 2003 03:25:42 +1100 Date: Thu, 13 Mar 2003 03:25:41 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Tim Robbins Cc: current@FreeBSD.ORG Subject: Re: failed to set signal flags properly for ast() In-Reply-To: <20030312141804.A12375@dilbert.robbins.dropbear.id.au> Message-ID: <20030313023818.O450@gamplex.bde.org> References: <20030312141804.A12375@dilbert.robbins.dropbear.id.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, 12 Mar 2003, Tim Robbins wrote: > Compile, run under gdb, then type "print test()" when the program receives > SIGABRT. Seems to work incorrectly on 4.7 too. > > #include > #include > > void > test(void) > { > > puts("hello"); > } > > int > main(int argc, char *argv[]) > { > > abort(); > exit(0); > } Thanks. At last it is possible to reproduce this bug :-). The bug seems to be that issignal() is quite broken. It gets called for masked signals in the P_TRACED case, but never does anything for masked signals, but at least the following things poing to a need for doing something for masked signals: - the special case for P_TRACED in SIGPENDING() - the incorrect behaviour of the above program in RELENG_4. I think it misbehaves in the same way under -current except in the INVARIANTS case the sanity check spews kernel printfs. - code in NetBSD's issignal() to do something in the (p->p_stat == SSTOP) case without even checking if there are any signals (masked or not). This bug seems to go back to at least FreeBSD-1 (Net/2). SIGPENDING() is also inconsistent with issignal() in the P_PPWAIT case. I think this just wastes time doing null calls to issignal(), and triggers the INVARIANTS check in the same way as the P_TRACED case (see below). This seems to go back to FreeBSD-1 too. SIGPENDING() is consistent with issignal() in the S_SIG case, but this may be wrong since S_SIG is similar to P_TRACED. The invariants check gets trigger as follows: - sigpending() is called correctly. - ast() clears the flags set by sigpending() and "handles" the signal using "while ((sig == cursig(td)) != 0) postsig()". But cursig() doesn't find any signals since all the pending ones are masked. - userret() checks that pending signals were handled. It finds unhandled masked ones and thinks they needed handling because P_TRACED is set. (IIRC, there is only a SIGTRAP pending to begin with, but attempting to control the process using ^C^Z gave masked SIGINTs and SIGSTOPs too). Appart from the diagnostic, the incorrect working in -current is to loop endlessly calling ast() and usrret(). ^C^Z doesn't stop it because they are masked. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message