Hi, Mads,

You mentioned that "if...is trivial enough, it will not trigger a
stack guard check. "

I found the following script can't be terminated by
v8::V8::TerminateExecution(), is it caused by the reason you mentioned
above?

   for (;;)
   {
         print("Still running");
   }


If we want to terminate the above script, what should we do?
There is another overloaded API   v8::V8::TerminateExecution(int
threadID), will that works?


Reproduction steps:
-----------------------------
There is a test-thread-termination.cc under project ccTest,
Change function Doloop to following, then the test case
"test-thread-termination/TerminateOnlyV8ThreadFromThreadItself" will
fail
v8::Handle<v8::Value> DoLoop(const v8::Arguments& args) {
  v8::TryCatch try_catch;
  //v8::Script::Compile(v8::String::New("function f() {"
  //                                    "  var term = true;"
  //                                    "  try {"
  //                                    "    while(true) {"
  //                                    "      if (term) terminate
();"
  //                                    "      term = false;"
  //                                    "    }"
  //                                    "    fail();"
  //                                    "  } catch(e) {"
  //                                    "    fail();"
  //                                    "  }"
  //                                    "}"
  //                                    "f()"))->Run();
  v8::Script::Compile(v8::String::New("var term = true; while(true)
{if
(term) terminate(); term = false;}"))->Run();
  CHECK(try_catch.HasCaught());
  CHECK(try_catch.Exception()->IsNull());
  CHECK(try_catch.Message().IsEmpty());
  CHECK(!try_catch.CanContinue());
  return v8::Undefined();
}


On Sep 3, 7:12 pm, Mads Sig Ager <[email protected]> wrote:
> Hi Ondrej,
>
> the actual termination is not carried out immediately but at the next
> stack guard check.  If your doSomethingElse is trivial enough, it will
> not trigger a stack guard check.  However, if it contains calls or
> loops it should hit the termination.
>
> Have a look at test/cctest/test-thread-termination.cc for examples.
>
> Cheers,    -- Mads
>
>
>
> On Thu, Sep 3, 2009 at 1:05 PM, ondras<[email protected]> wrote:
>
> > Hi,
>
> > how exactly is the new feature "execution termination" supposed to
> > work? I created a JS function "exit", which performs
> > "v8::V8::TerminateExecution()". However, the following code:
>
> > doSomething();
> > exit();
> > doSomethingElse();
>
> > seems to ignore the termination command, because doSomethingElse gets
> > normally executed...
>
> > Thanks,
> > Ondrej

--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to