From owner-freebsd-threads@FreeBSD.ORG Fri Jun 11 06:29:22 2004 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7436216A4CE; Fri, 11 Jun 2004 06:29:22 +0000 (GMT) Received: from mail.mcneil.com (rrcs-west-24-199-45-54.biz.rr.com [24.199.45.54]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6526943D41; Fri, 11 Jun 2004 06:29:22 +0000 (GMT) (envelope-from sean@mcneil.com) Received: from localhost (localhost.mcneil.com [127.0.0.1]) by mail.mcneil.com (Postfix) with ESMTP id 44A83FD059; Thu, 10 Jun 2004 23:29:20 -0700 (PDT) Received: from mail.mcneil.com ([127.0.0.1]) by localhost (server.mcneil.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 38633-08; Thu, 10 Jun 2004 23:29:19 -0700 (PDT) Received: from [24.199.45.54] (mcneil.com [24.199.45.54]) by mail.mcneil.com (Postfix) with ESMTP id BF4BAFD01A; Thu, 10 Jun 2004 23:29:19 -0700 (PDT) From: Sean McNeil To: David Xu In-Reply-To: <40C94B1E.8030202@freebsd.org> References: <1086931276.38487.35.camel@server.mcneil.com> <40C94B1E.8030202@freebsd.org> Content-Type: text/plain Message-Id: <1086935359.85387.14.camel@server.mcneil.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Thu, 10 Jun 2004 23:29:19 -0700 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mcneil.com cc: freebsd-threads@freebsd.org Subject: Re: signal handler priority issue X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jun 2004 06:29:22 -0000 On Thu, 2004-06-10 at 23:03, David Xu wrote: > I think there is a race in GC_suspend_handler, > code between sem_post and sigsuspend has race, let me demostrate: > > Master : pthread_kill(slave1, SIGUSR1); > Master : semwait > Slave1 : sempost > Master : semwait return > Master : pthread_kill(slave, SIGUSR2); > Master : pthread_kill(slave2, SIGUSR1); > ... > Slave1 : scheduler switched to slave1, found there > is SIGUSR2 in pending set > Slave1 : invoke SIGUSR2 handler withinsa_handler > Slave1 : SIGUSR2 handler return > Slave1 : sigsuspend SIGUSR2 > because SIGUSR2 was already handled, it hangs > in sigsuspend, and never return. > > It seems the code has the race bug. I think you should > use sigaction and set additional mask for SIGUSR1. > code looks like this: > > struct sigaction sa; > > sigemptyset(&sa.sa_mask); > sigaddset(&sa.sa_mask, SIGUSR2); > sa.sa_handler = GC_suspend_handler; > sigaction(SIGUSR1, &sa, NULL); > > this code will block out SIGUSR2 in GC_suspend_handler, > and when you call sigsuspend for SIGUSR2, it should return > if there is SIGUSR2 pending or it SIGUSR2 comes later. Actually, what I think is happening now is that the sigaction for SIGUSR2 is being called but the sigsuspend isn't being release.