I require the ability to run user-supplied js code, but I want to 
unceremoniously abort bad-behaving code *without* crashing the entire 
process.  A fall back to the outermost call to js where the encompassing 
TryCatch indicates an inability to continue would be ideal, but I cannot 
find any documented API that would enable this.

What I have tried so far is the following:
Adding a fatal error handler via SetFatalErrorHandler, and invoking 
TerminateExecution on the isolate within that.   This does not keep the 
program from crashing however.

I have tried using AddMemoryAllocationCallback and monitoring how much 
memory gets allocated, but this function does not seem to report everything 
that is needed by the script. In one particular instance, the callback only 
reported that a couple of megabytes of reported allocation in this callback 
before encountering a crash when I know that the offending program was 
trying to use far more memory than that, having several arrays that were 
many tens of megabytes in size.

What I *have* noticed, although I do not know if I can rely upon this as 
defined behaviour, is that in the callback added via 
AddMemoryAllocationCallback, I *do* get a Free memory invocation that wants 
to release everything that has been allocated so far, and this does not 
seem to happen when the js is well behaved (as I can remove the callback 
when I have finished calling the js), so within this callback, I can 
successfully call TerminateExecution on the isolate in this case and my 
handling at the outermost call to js can be captured by seeing that its 
TryCatch is unable to continue, but I have no idea if I can actually rely 
on this behavior to do what I want, or if this is just a coincidence that 
it seems to work in the limited cases that I have tried.

Is there any official way to do this, or is v8 simply unsuitable for use 
within a process that needs to run possibly user-provided js code?

-- 
-- 
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.

Reply via email to