Program crash when using JS_NewGlobalObject: SpiderMonkey

I use the latest version of SpiderMonkey (js185-1.0.0.tar.gz), and when I run the sample program in which Javascript is built in, the program crashes

A sample program is found directly from the documents.

The program works fine if I use JS_NewCompartmentAndGlobalObject but the docs mention the use of JS_NewGlobalObject as it is "deprecated with JSAPI 16"

So I replaced JS_NewCompartmentAndGlobalObject with JS_NewGlobalObject , and since then the sample program will run on line: 55 in the sample program found here

What is the solution here?

I am using the 64-bit version of CentOS 6.2.

+6
source share
1 answer

The deviation is most likely due to a recent change with how compartments are created in SM (now each new global will get its own default branch).

You should use JS_NewCompartmentAndGlobalObject since this function was deprecated only in JSAPI 16, 72 weeks after the release of JS 1.8.5 :)

+2
source

All Articles