Re: Uncatchable exceptions

Ehsan Akhgari <[email protected]>
Newsgroups gmane.comp.mozilla.devel.jseng
Message-ID <[email protected]>
I guess I may have not been clear enough in my original post, let me try
again!

The V8 API exposes the notion of "terminating exceptions" which are
exceptions that terminate the execution of JS but are not catchable *in*
JS.  I'll call these "uncatchable exceptions".

SpiderMonkey has the exact same notion internally.  I'd like to find a
way to implement the corresponding V8 APIs, which will require exposing
some kind of JS API, like JS_IsUncatchableExceptionPending(JSContext*).

I'm trying to figure out how to implement this function.  AFAICT the
implementation is roughly as follows:

bool JS_IsUncatchableExceptionPending(JSContext* cx) {
  return cx->didSomeJSNativeReturnFalse() ||
         cx->isThrowingOutOfMemory();
}

It is the didSomeJSNativeReturnFalse() that I don't know how to
implement.  As far as I can understand stuff that happens in js::Call()
et al, there isn't even a flag indicating such case. :(  It seems like
all that happens here is we return false and pass the ball to the
caller, which itself returns false and so on.

Can someone please help with how I can extract this information from
SpiderMonkey()?

Thanks,
Ehsan

On 2016-05-02 5:46 PM, Bobby Holley wrote:
> Historically, returning false without setting a pending exception was
> considered uncatchable, and was the way to signal OOM, terminate slow
> scripts, etc. The idea is that callers are always supposed to propagate
> |false| return values, and if there wasn't any associated exception
> state, there was nothing they could do but propagate it upward.
> 
> Recently, OOMs were converted to use some kind of pseudo-exception on
> the JSContext. There is some related discussion at [1]. I think that the
> slow script dialog / interrupt callback mechanism still uses plain
> |return false|, but I haven't checked.
> 
> [1]
> https://groups.google.com/d/msg/mozilla.dev.tech.js-engine.internals/6icIj0U0wDo/T70QBToLBwAJ
> 
> On Mon, May 2, 2016 at 2:15 PM, Ehsan Akhgari <[email protected]
> <mailto:[email protected]>> wrote:
> 
>     AFAIK there is some notion of uncatchable exceptions in SpiderMonkey in
>     case a JSNative returns false, which is used in Gecko.  Are there other
>     similar cases in SpiderMonkey?  There doesn't seem to be any way to
>     raise/detect such exceptions through the JS API.
> 
>     Also, is there any notion of terminating the execution of JS through
>     other
>     means?
> 
>     Thanks,
>     --
>     Ehsan
>     _______________________________________________
>     dev-tech-js-engine mailing list
>     [email protected]
>     <mailto:[email protected]>
>     https://lists.mozilla.org/listinfo/dev-tech-js-engine
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.