-
Notifications
You must be signed in to change notification settings - Fork 7.3k
timers: float delays can cause 100% cpu usage. #8067
timers: float delays can cause 100% cpu usage. #8067
Conversation
The changes in befbbad switch all comparisons over to unsigned integer comparisons, but in certain cases list.msecs will be fractional. If this is the case, the timer will never be removed from the list. This fixes the issue by casting msecs to an integer by rounding up or down. Fixes 8065.
The actual issue is that when we call start with a timeout argument whole value is >= 0 and < 1 (note the use of the strict inequality), it creates an infinite recursion that follows the following pattern:
Before befbbad, This problem doesn't happen on master because of 93b0624. Applying this change to v0.10.30 fixes the issue, and it doesn't break any test. What is your opinion about this @tjfontaine? @chrisdickinson I am not sure using We could also fix this issue without too much impact on other code by clamping the timeout parameter that is passed to My preference goes to backporting 93b0624 . @chrisdickinson @tjfontaine What do you guys think? I'd rather proceed with caution with this one, since I'm the one who broke 0.10.30. Last but not least, thank you @chrisdickinson for all your help! |
@chrisdickinson I thought about a strategy to test this issue reliably, but I haven't come up with anything yet. Please let me know if you find out anything. Thank you again! |
@misterdjules That all looks correct to me -- thanks for the great writeup! So, there should be some protection against |
@chrisdickinson Great, that gives us another candidate for a fix. What I like about the solution that backports 93b0624 is that it seems more general. For instance, I think that your fix would leave To a lesser extent, ceiling |
@chrisdickinson I've added a repro for the same issue as #8065, but this time for internal timers. With the fix that ceils With the backport of 93b0624, the issue with internal timers is fixed too. |
I can consistently reproduce this in my app for v0.10.30 (ran into it just this morning). Will possibly cause a lot of headaches since this version is a recommended upgrade based on the v8 issue. |
We need to backport 93b0624 as well, I'm sorry I missed that during review |
@tjfontaine OK, I'll send you a PR that backports 93b0624 asap. |
Just for the record, PR submitted here: #8073 . |
Closing this in favor of #8073. |
The changes in befbbad switch all comparisons over to unsigned
integer comparisons, but in certain cases list.msecs will be fractional.
If this is the case, the timer will never be removed from the list.
This fixes the issue by casting msecs to an integer by rounding up
or down.
Fixes #8065.
I might need some advice on how best to test this. The below script will intermittently freeze and block the event loop, but I can't reliably trigger this behavior 100% of the time -- there is a small percentage of times where it'll run to completion.