Ticket #5151 defect closed fixed
_SIGCHLDWaker in twisted.internet.posixbase doesn't check its pipe is still open when registering signal handlers
|Reported by:||hodgestar||Owned by:||hodgestar|
(diff, github, buildbot, log)
|Author:||itamarst, hodgestar||Launchpad Bug:|
The function install in _SIGCHLDWaker looks like:
def install(self): """ Install the handler necessary to make this waker active. """ _signals.installHandler(self.o)
Here self.o may evaluate to None causing installHandler to throw an exception. This may happen if connectionLost is somehow called before installHandler.
One possible fix is:
def install(self): """ Install the handler necessary to make this waker active. """ if self.o is not None: _signals.installHandler(self.o)
I've observed this in the wild inside a moderately complex test suite. Assistance in understanding the "somehow" that causes self.o to become None would be appreciated.
The following note inside _handleSignals in posixbase might be relevant since it explains one possible scenario in which related code may be executed before the event handlers are installed:
# Also reap all processes right now, in case we missed any # signals before we installed the SIGCHLD waker/handler. # This should only happen if someone used spawnProcess # before calling reactor.run (and the process also exited # already).