1031: JS_SetErrorReporter only once per JSRuntime.
commitb94657869bc90b5c42693c28c472f041a80fced1
authorKalle Olavi Niemitalo <kon@iki.fi>
Sun, 7 Sep 2008 16:39:26 +0000 (7 19:39 +0300)
committerKalle Olavi Niemitalo <Kalle@Astalo.kon.iki.fi>
Sun, 7 Sep 2008 17:17:25 +0000 (7 20:17 +0300)
tree4310690a802beda74d4651d5728f0cf0fe35b743
parent0ee1d05d8147072ce87893c8876745d481183627
1031: JS_SetErrorReporter only once per JSRuntime.

Previously, spidermonkey_get_interpreter() and init_smjs() each called
JS_SetErrorReporter on the JSContexts they created.  However,
JS_SetErrorReporter actually sets the error reporter of the JSRuntime
associated with the JSContext, and all of our JSContexts use the same
JSRuntime nowadays, so only the error_reporter() of
src/ecmascript/spidermonkey.c was left installed.  Because this
error_reporter() asserts that JS_GetContextPrivate(ctx) returns a
non-NULL pointer, and init_smjs() does not set a private pointer for
smjs_ctx, any error in smjs_ctx could cause an assertion failure, at
least in principle.

Fix this by making spidermonkey_runtime_addref() install a shared
error_reporter() when it creates the JSRuntime and the first JSContext.
The shared error_reporter() then checks the JSContext and calls the
appropriate function.

The two error reporters are quite similar with each other.  In the
future, we could move the common code into shared functions.  I'm not
doing that yet though, because fixing the bug doesn't require it.
src/ecmascript/spidermonkey-shared.c
src/ecmascript/spidermonkey.c
src/ecmascript/spidermonkey.h
src/scripting/smjs/core.c
src/scripting/smjs/core.h