Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Program crashes if using JS_NewGlobalObject : SpiderMonkey

I am using the latest release of SpiderMonkey (js185-1.0.0.tar.gz) and when I am running the sample program which embeds Javascript, crashes the program

The sample program is directly from the docs

The program runs fine if I am using JS_NewCompartmentAndGlobalObject but the docs mention to use JS_NewGlobalObject as it is "Obsolete since JSAPI 16"

Hence I replaced the JS_NewCompartmentAndGlobalObject with JS_NewGlobalObject and since then the sample program crashes at line: 55 in the sample program found here

What is the solution here?

I am using CentOS 6.2 64-bit version.

like image 622
Ashwin Avatar asked Oct 29 '12 10:10

Ashwin


1 Answers

The deprecation is likely related to the recent change to how compartments are created in SM (now every new global will get its own compartment by default).

You should be using JS_NewCompartmentAndGlobalObject, as that function was only deprecated in JSAPI 16, 72 weeks after JS 1.8.5 was released :)

like image 149
Reuben Morais Avatar answered Oct 25 '22 14:10

Reuben Morais