_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).
Change History (33)
Changed 4 years ago by exarkun
comment:14 follow-up: ↓ 16 Changed 4 years ago by exarkun
- Keywords review removed
- Owner changed from exarkun to hodgestar
comment:21 Changed 4 years ago by hodgestar
- Owner hodgestar deleted
- Status changed from assigned to new
comment:26 Changed 12 months ago by itamarst
- Branch changed from branches/process-exited-errors-5151 to branches/process-exited-errors-5151-2