You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version: 8.8.1
Platform: Linux jamie-Lenovo-K450e 4.8.0-56-generic #61~16.04.1-Ubuntu SMP Wed Jun 14 11:58:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Subsystem: node_watchdog.cc (affects the VM module)
Here's code from node_watchdog.cc, which is used in node_contextify.cc to time out runaway executions in a VM context.
In the destructor, we uv_async_send to trigger Watchdog::Async.
It may be that Watchdog::Async goes off before Watchdog::Timer, in which case we would like the Timer not to do anything -- specifically, it should neither publish timed_out_ nor call TerminateExecution.
From the libuv docs (and code), it looks to me like the Timer currently won't be triggered if the Async goes off first and calls uv_stop, but I might be mistaken.
Certainly the Async will always go off, so if the Timer goes off first then we will have Timer -> Async.
Suggestion
Whether or not Async -> Timer can currently happen, I think relying on the libuv loop ordering like this is in poor taste. It looks like the idea is for exactly one of Async and Timer to take effect. Adding internal aborted and timed_out flags and setting/testing the appropriate flag in Async and in Timer would give us this guarantee.
PR
I have a patch that generalizes Watchdog to call an aborted_cb and a timed_out_cb and will only call one of them, plus an appropriate modification to node_contextify.cc.
Would either component of this patch be of interest?
The text was updated successfully, but these errors were encountered:
addaleax
added
libuv
Issues and PRs related to the libuv dependency or the uv binding.
vm
Issues and PRs related to the vm subsystem.
labels
Nov 3, 2017
Libuv's event loop phases are well-documented. Relying on their order in the watchdog is fine.
From the libuv docs (and code), it looks to me like the Timer currently won't be triggered if the Async goes off first and calls uv_stop, but I might be mistaken.
No, both can happen. The 'is stopped?' check is done only once per event loop "tick."
It may be that Watchdog::Async goes off before Watchdog::Timer, in which case we would like the Timer not to do anything -- specifically, it should neither publish timed_out_ nor call TerminateExecution.
The scenario you describe only happens when both fire in the same tick. I don't see the current implementation as wrong because the exact timing of the async event is essentially arbitrary.
So If the Async and the Timer can both fire in the same tick, with the Async preceding the Timer, then the Timer will call TerminateExecution even though the script completed. Could this have any ill effect?
Version: 8.8.1
Platform: Linux jamie-Lenovo-K450e 4.8.0-56-generic #61~16.04.1-Ubuntu SMP Wed Jun 14 11:58:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Subsystem: node_watchdog.cc (affects the VM module)
Here's code from node_watchdog.cc, which is used in node_contextify.cc to time out runaway executions in a VM context.
Summary of behavior
uv_async_send
to trigger Watchdog::Async.TerminateExecution
.Suggestion
Whether or not Async -> Timer can currently happen, I think relying on the libuv loop ordering like this is in poor taste. It looks like the idea is for exactly one of Async and Timer to take effect. Adding internal
aborted
andtimed_out
flags and setting/testing the appropriate flag in Async and in Timer would give us this guarantee.PR
I have a patch that generalizes Watchdog to call an aborted_cb and a timed_out_cb and will only call one of them, plus an appropriate modification to node_contextify.cc.
Would either component of this patch be of interest?
The text was updated successfully, but these errors were encountered: