Handle invalid Continuation state at start time

In an unlikely situation a user of ext_asio may tamper with Continuation
before passing it to the ext_asio extension. Let's fail with an
exception if this happens. Previously, a user bug would stay unnoticed,
but would not harm the ext_asio code.

This check will be needed once we implement optimistic execution. With
optimistic execution, we iterate continuation and defer construction of
ContinuationWaitHandle until the first blocking event occurs. During
this phase, a standard dependency loop detection is skipped and the code
would try to iterate a continuation that is already being iterated.
Esse commit está contido em:
jan
2013-03-25 13:11:25 -07:00
commit de Sara Golemon
commit a131e5232e
@@ -71,6 +71,14 @@ Object c_ContinuationWaitHandle::ti_start(const char* cls, CObjRef continuation)
return cont->m_waitHandle;
}
if (UNLIKELY(cont->m_index != -1)) {
Object e(SystemLib::AllocInvalidOperationExceptionObject(
cont->m_running
? "Encountered an attempt to start currently running continuation"
: "Encountered an attempt to start tainted continuation"));
throw e;
}
p_ContinuationWaitHandle wh = NEWOBJ(c_ContinuationWaitHandle)();
wh->start(cont, depth + 1);
if (UNLIKELY(session->hasOnStartedCallback())) {