Subject: Re: port-sparc64/29824
To: None <port-sparc64-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: Matthias Scheler <tron@zhadum.de>
List: netbsd-bugs
Date: 05/01/2005 21:45:02
The following reply was made to PR port-sparc64/29824; it has been noted by GNATS.

From: Matthias Scheler <tron@zhadum.de>
To: Chuck Silvers <chuq@chuq.com>
Cc: port-sparc64-maintainer@netbsd.org, xsrc-manager@netbsd.org,
	netbsd-bugs@netbsd.org, NetBSD GNATS <gnats-bugs@netbsd.org>,
	macallan18@earthlink.net
Subject: Re: port-sparc64/29824
Date: Sun, 1 May 2005 22:44:20 +0100

 On Sun, May 01, 2005 at 02:37:17PM -0700, Chuck Silvers wrote:
 > > Responsible-Changed-From-To: xsrc-manager->port-sparc64-maintainer
 > > Responsible-Changed-By: tron@netbsd.org
 > > Responsible-Changed-When: Sun, 01 May 2005 18:14:03 +0000
 > > Responsible-Changed-Why:
 > > 1.) XFree86's signal handling code does *not* cause this. It will not
 > >     unblock SIGIO from a the SIGIO signal handler.
 > 
 > I just read the code again, it sure looks like it does to me.
 > the call stack in the initial PR comments looks like it could really happen.
 
 How?
 
 
 1.) xf86BlockSIGIO() returns whether the signal has been blocked before:
 
 int
 xf86BlockSIGIO (void)
 {
     sigset_t    set, old;
 
     sigemptyset (&set);
     sigaddset (&set, SIGIO);
     sigprocmask (SIG_BLOCK, &set, &old);
     return sigismember (&old, SIGIO);
 }
 
 2.) xf86SigioReadInput() remembers that flag and passed it to
     xf86UnblockSIGIO():
 
 static void
 xf86SigioReadInput(int fd,
                    void *closure)
 {
     int sigstate = xf86BlockSIGIO();
 [...]
     xf86UnblockSIGIO(sigstate);
 }
 
 3.) void xf86UnblockSIGIO() only unblocks the signal if it has not been
     blocked before:
 
 void
 xf86UnblockSIGIO (int wasset)
 {
     sigset_t    set;
 
     if (!wasset)
     {
         sigemptyset (&set);
         sigaddset (&set, SIGIO);
         sigprocmask (SIG_UNBLOCK, &set, NULL);
     }
 }
 
 That looks safe to me.
 
 	Kind regards
 
 -- 
 Matthias Scheler                                  http://scheler.de/~matthias/