6

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.

Ashwin
  • 1,942
  • 4
  • 30
  • 59
  • The program sample you cite is dated February 2000. The program may contain several obsolete functions, not just `JS_NewCompartmentAndGlobalObject`. I would source another sample program from a more recent spidermonkey document. – damienh Oct 29 '12 at 11:13
  • 1
    @damienh: Compartments were introduced around Firefox 4 - quite definitely after February 2000 ;). February 2000 was the modification date of the document imported into MDN (this import happened in April 2006 according to the document history), it got quite a few changes since then however - most recent one in June this year. Still, this document refers to the JSAPI User Guide for better examples. – Wladimir Palant Oct 29 '12 at 20:15

1 Answers1

2

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 :)

Reuben Morais
  • 1,013
  • 1
  • 8
  • 20