Re: [v8-users] Setting an execution limit

2016-11-21 Thread Jakob Kummerow
There is always a stack limit, which always prevents infinite recursion; as
well as, in fact, finite but very deep recursion.

As Ben said, the only way to prevent infinite or long-running loops is by
interrupting the program from another thread. You may have heard of
the *Halting
Problem*, TL;DR: there really can be no other way, because in the general
case it is *impossible* to predict whether a loop will terminate at all,
and how soon.

There is no way to set a limit for executed instructions. You could hack
it, but it's going to be non-trivial.

On Sun, Nov 20, 2016 at 11:11 PM,  wrote:

> I don't think there's any way. V8 JavaScript code is compiled to native
> code, and no instrumentation is really possible on that.
>
> On Sunday, November 20, 2016 at 10:18:24 AM UTC-8, James Lovejoy wrote:
>>
>> Really I need something a little more deterministic than a time limit. Is
>> there a way to set an instruction limit? Or perhaps something similar to
>> lua_sethook (http://pgl.yoyo.org/luai/i/lua_sethook) in Lua which calls
>> a callback every given number of instructions.
>>
>> On Sun, Nov 20, 2016 at 4:02 AM, Ben Noordhuis 
>> wrote:
>>
>>> On Sat, Nov 19, 2016 at 10:11 PM, James Lovejoy 
>>> wrote:
>>> > Hi,
>>> >
>>> > Is there a way to set a hard execution limit in the V8 engine? I want
>>> to be
>>> > able to prevent things like infinite loops and recursions. I realise
>>> that
>>> > since V8 compiles to machine code I don't get a program counter or
>>> anything.
>>> > I feel like setting the "stack limit" is the right way to go but the
>>> usage
>>> > of this feature from the documentation is unclear. Can someone guide
>>> me as
>>> > to how to achieve such a limit?
>>> >
>>> > James
>>>
>>> If 'execution limit' means 'time limit': start a watchdog thread and
>>> call v8::Isolate::TerminateExecution() from that thread on timeout.
>>> It must be a thread, it's not safe to call from a signal handler.
>>>
>>> --
>>> --
>>> v8-users mailing list
>>> v8-u...@googlegroups.com
>>> http://groups.google.com/group/v8-users
>>> ---
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "v8-users" group.
>>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>>> pic/v8-users/Qwdd66xCtTU/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> v8-users+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Setting an execution limit

2016-11-20 Thread tblodt
I don't think there's any way. V8 JavaScript code is compiled to native 
code, and no instrumentation is really possible on that.

On Sunday, November 20, 2016 at 10:18:24 AM UTC-8, James Lovejoy wrote:
>
> Really I need something a little more deterministic than a time limit. Is 
> there a way to set an instruction limit? Or perhaps something similar to 
> lua_sethook (http://pgl.yoyo.org/luai/i/lua_sethook) in Lua which calls a 
> callback every given number of instructions.
>
> On Sun, Nov 20, 2016 at 4:02 AM, Ben Noordhuis  > wrote:
>
>> On Sat, Nov 19, 2016 at 10:11 PM, James Lovejoy > > wrote:
>> > Hi,
>> >
>> > Is there a way to set a hard execution limit in the V8 engine? I want 
>> to be
>> > able to prevent things like infinite loops and recursions. I realise 
>> that
>> > since V8 compiles to machine code I don't get a program counter or 
>> anything.
>> > I feel like setting the "stack limit" is the right way to go but the 
>> usage
>> > of this feature from the documentation is unclear. Can someone guide me 
>> as
>> > to how to achieve such a limit?
>> >
>> > James
>>
>> If 'execution limit' means 'time limit': start a watchdog thread and
>> call v8::Isolate::TerminateExecution() from that thread on timeout.
>> It must be a thread, it's not safe to call from a signal handler.
>>
>> --
>> --
>> v8-users mailing list
>> v8-u...@googlegroups.com 
>> http://groups.google.com/group/v8-users
>> ---
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "v8-users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/v8-users/Qwdd66xCtTU/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> v8-users+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Setting an execution limit

2016-11-20 Thread James Lovejoy
Really I need something a little more deterministic than a time limit. Is
there a way to set an instruction limit? Or perhaps something similar to
lua_sethook (http://pgl.yoyo.org/luai/i/lua_sethook) in Lua which calls a
callback every given number of instructions.

On Sun, Nov 20, 2016 at 4:02 AM, Ben Noordhuis  wrote:

> On Sat, Nov 19, 2016 at 10:11 PM, James Lovejoy 
> wrote:
> > Hi,
> >
> > Is there a way to set a hard execution limit in the V8 engine? I want to
> be
> > able to prevent things like infinite loops and recursions. I realise that
> > since V8 compiles to machine code I don't get a program counter or
> anything.
> > I feel like setting the "stack limit" is the right way to go but the
> usage
> > of this feature from the documentation is unclear. Can someone guide me
> as
> > to how to achieve such a limit?
> >
> > James
>
> If 'execution limit' means 'time limit': start a watchdog thread and
> call v8::Isolate::TerminateExecution() from that thread on timeout.
> It must be a thread, it's not safe to call from a signal handler.
>
> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "v8-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/v8-users/Qwdd66xCtTU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> v8-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Setting an execution limit

2016-11-20 Thread Ben Noordhuis
On Sat, Nov 19, 2016 at 10:11 PM, James Lovejoy  wrote:
> Hi,
>
> Is there a way to set a hard execution limit in the V8 engine? I want to be
> able to prevent things like infinite loops and recursions. I realise that
> since V8 compiles to machine code I don't get a program counter or anything.
> I feel like setting the "stack limit" is the right way to go but the usage
> of this feature from the documentation is unclear. Can someone guide me as
> to how to achieve such a limit?
>
> James

If 'execution limit' means 'time limit': start a watchdog thread and
call v8::Isolate::TerminateExecution() from that thread on timeout.
It must be a thread, it's not safe to call from a signal handler.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[v8-users] Setting an execution limit

2016-11-19 Thread James Lovejoy
Hi,

Is there a way to set a hard execution limit in the V8 engine? I want to be 
able to prevent things like infinite loops and recursions. I realise that 
since V8 compiles to machine code I don't get a program counter or 
anything. I feel like setting the "stack limit" is the right way to go but 
the usage of this feature from the documentation is unclear. Can someone 
guide me as to how to achieve such a limit?

James

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.