Opened 12 years ago

Last modified 12 years ago

#3884 defect new

Reactors break if a DelayedCall is scheduled with .time = NaN

Reported by: bdew Owned by: bdew
Priority: low Milestone:
Component: core Keywords:
Cc: Branch:


I'm currently debugging allmydata-tahoe issue #737 the problem there seems to be that somehow a delayed call is scheduled with a time of NaN, this leads to 2 problems in the reactor

1) ReactorBase.runUntilCurrent() won't run that call or anything later

while self._pendingTimedCalls and (self._pendingTimedCalls[0].time <= now)

because NaN compared with anything always returns false - this loop never runs and no other calls after the bugged one in self._pendingTimedCalls will ever run.

Also this and any later call will never be removed even if canceled - this loop handles cancelations too.

2) ReactorBase.timeout() returns 0 when that call is in _pendingTimedCalls[0]

This will make the reactor do iterations with 0 timeout, which on most (all?) reactors will lead to 100% CPU usage

Minimal code to demonstrate this bug:

from twisted.internet import reactor

def foo():

def setup():


foo() is never called, the reactor never stops and the process eats 100% CPU, i've tested this on twisted 8.2.0 on windows (select reactor) and linux (poll reactor)

I know setting the timeout to NaN is not something sane to do, but i think twisted should break less horibly when some other bug causes that to happen ;)

Change History (3)

comment:1 Changed 12 years ago by Glyph

Owner: changed from Glyph to bdew
Priority: normallow

I agree, it would be better if Twisted handled this more sanely. Care to contribute a patch? :)

comment:2 Changed 12 years ago by Glyph

(My suggestion would be "raise an exception from reset", as NaN is not really a valid value to reset anything with; just as it should raise an exception if you tried to reset it with a list, or as exarkun put it, "a toad".)

comment:3 Changed 12 years ago by Jean-Paul Calderone

Cc: tahoe-dev@… removed

tahoe-dev@… bounces mails from trac, removing from cc.

Note: See TracTickets for help on using tickets.