Message from discussion
Locker, Preemption and TerminateExecution() method;
Received: by 10.68.66.2 with SMTP id b2mr1246382pbt.101.1305057023983;
Tue, 10 May 2011 12:50:23 -0700 (PDT)
X-BeenThere: v8-users@googlegroups.com
Received: by 10.68.1.5 with SMTP id 5ls10804271pbi.1.gmail; Tue, 10 May 2011
12:50:22 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.68.13.231 with SMTP id k7mr966686pbc.16.1305057022470; Tue, 10
May 2011 12:50:22 -0700 (PDT)
Received: by z15g2000prn.googlegroups.com with HTTP; Tue, 10 May 2011 12:50:22
-0700 (PDT)
Date: Tue, 10 May 2011 12:50:22 -0700 (PDT)
In-Reply-To: <BANLkTimQO1ptB9t+csC36M6q9FmDNtBfcA@mail.gmail.com>
X-IP: 64.128.133.180
References: <be85548b-b1a2-43a3-bfa8-2112e0d4cbc6@j31g2000yqe.googlegroups.com>
<98c15bf6-33a4-4616-a3fc-d16ce81a1629@dn9g2000vbb.googlegroups.com> <BANLkTimQO1ptB9t+csC36M6q9FmDNtBfcA@mail.gmail.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24
(KHTML, like Gecko) Chrome/11.0.696.60 Safari/534.24,gzip(gfe)
Message-ID: <7c02a72e-aecb-43f5-a079-c508564a3d02@z15g2000prn.googlegroups.com>
Subject: Re: Locker, Preemption and TerminateExecution() method;
From: Chinnu <chinnu4...@gmail.com>
To: v8-users <v8-users@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Thank you for the replies.
The specific issue I'm trying to tackle is the one mentioned by mcot
above - running java script that could have infinite loops within it.
Currently, there is no way to come out of these infinitely running
scripts, which is understandable from a browser'd perspective (where
the user can chose to kill the browser window).
I do not have a simple code snippet to reproduce the issue with
TerminateExecution, but, will work on creating one. In the meantime,
if anyone has ideas on addressing the infinite loops in java script,
please let me know.
Thank you,
Ravi
On May 9, 1:54=A0am, Mads Sig Ager <a...@chromium.org> wrote:
> Could you create a reproduction of this issue and file a bug report?
> Execution termination throws an exception that cannot be caught by
> JavaScript. Control is returned to C++ activations (where the result
> will be an empty handle) so that C++ can do cleanup before returning
> to the calling JavaScript. When there is no more JavaScript frames on
> the stack you can continue using V8. Something might have broken in
> the termination support. If you can provide a stand-alone example
> program that reproduces the issue we can investigate.
>
> Thanks, =A0 =A0-- Mads
>
>
>
>
>
>
>
> On Sat, May 7, 2011 at 4:26 PM, mcot <atm1...@gmail.com> wrote:
> > Ok... so the problem with terminate execution is that it will
> > completely kill a given isolate (as far as I can tell). =A0What I think
> > that means is that all local handles are destroyed and all persistant
> > handles are disposed. =A0What I think you want (and also something I
> > want) is to be able to set a timeout for a single call to script-
> >>Run(). =A0There is a subtle difference here. =A0If your application cal=
ls
> > Run many times and is using a single isolate then we still have a
> > problem thats not solved by V8 (as far as I can tell).
>
> > Hopefully a V8 dev will come in here and explain this better and
> > hopefully offer a solution that I am not seeing. =A0However, if we get
> > enough interest in this, I want to suggest a formal feature
> > enhancement to the V8 team to add a parameter to the Run function that
> > takes a timeout and maybe also a callback for when the timeout is
> > exceeded.
>
> > Here is the scenario I want to solve:
>
> > 1.) My application is not threaded and it uses a single isolate.
> > 2.) My application calls Run() many times. =A0It does some work in C++,
> > calls Run() to run some JS supplied by a user, does some work in C++,
> > calls Run() ect...
> > 3.) The JS supplied by the user could have infinite loops or long
> > running functions where the JS code is not calling into C++ (where I
> > could prevent them from running).
>
> > On May 6, 9:18=A0am, Chinnu <chinnu4...@gmail.com> wrote:
> >> Hi,
>
> >> I've been trying to implement a way to limit the execution time of a
> >> script in V8. I've seen some previous posts that suggest using Locker
> >> and Preemption (which effectively schedules the thread) and check for
> >> timeout in the 'OnPreemtionReceived' method. If timeout exceeded,
> >> invoke TerminateExecution().
>
> >> However, invoking TerminateExecution() from within
> >> 'OnPreemptionReceived()' method is causing issues (I'm guessing it's
> >> leaving the stack in an unbalanced state).
>
> >> Is it wrong to invoke TerminateExecution() from within V8's code? Is
> >> there a better way to implement the limiting of execution time?
>
> >> Thank you,
> >> Ravi
>
> > --
> > v8-users mailing list
> > v8-users@googlegroups.com