_SIGCHLDWaker in twisted.internet.posixbase doesn't check its pipe is still open when registering signal handlers
|Reported by:||hodgestar||Owned by:||hodgestar|
branch-diff, diff-cov, branch-cov, buildbot
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).
Change History (33)
comment:14 follow-up: 16 Changed 6 years ago by
|Author:||exarkun → hodgestar|
|Owner:||changed from Jean-Paul Calderone to hodgestar|
comment:26 Changed 3 years ago by
|Author:||hodgestar → itamarst, hodgestar|
|Branch:||branches/process-exited-errors-5151 → branches/process-exited-errors-5151-2|