So I am trying to run a code on release 64 platform. I am using spidemonkey 1.8.5 . the following code crashes at line JS_NewObject(). My guess is it is related to GC triggered inside the API. I have tried other APIs that do the same thing, I've also tried BeginRequest and EndRequest. none of them helped.
The same code works perfectly when linked to Spidermonkey 1.7.
int InitJS()
{
m_jsRunTime = JS_NewRuntime(JS_RUN_TIME_MEM);
if ( NULL == m_jsRunTime )
{
return 0;
}
m_jsContext = JS_NewContext(m_jsRunTime, JS_CONTEXT_MEM);
if ( NULL == m_jsContext )
{
return 0;
}
//JS_BeginRequest(m_jsConetxt);//just to test no help
//ASSERT(m_jsContext);ASSERT(&JS_GLOBAL_CLASS);//these are fine. no null pointer
//JSObject *myObject = JS_NewObject(m_jsContext, &JS_GLOBAL_CLASS, NULL, NULL);//just to test->this also carshes
//m_jsGlobalObject = JS_NewObjectwithGivenProto(m_jsContext, &JS_GLOBAL_CLASS, NULL, NULL);//just to test ->identifeir not found
//m_jsGlobalObject = JS_ConstructObject(m_jsContext, &JS_GLOBAL_CLASS, NULL, NULL);//just to test->crashes
m_jsGlobalObject = JS_NewObject(m_jsContext, &JS_GLOBAL_CLASS, NULL, NULL);//the original line
if ( NULL == m_jsGlobalObject)
{
return 0;
}
if ( !JS_InitStandardClasses(m_jsContext, m_jsGlobalObject) )
{
return 0;
}
JS_EndRequest(m_jsContext);//just to test
return 1;
}
the core dump file points to this line in jsgcinlines.h
inline JSObject *
js_NewGCObject(JSContext *cx, js::gc::FinalizeKind kind)
{
JS_ASSERT(kind >= js::gc::FINALIZE_OBJECT0 && kind
<=js::gc::FINALIZE_OBJECT_LAST);
JSObject *obj = NewFinalizableGCThing<JSObject>(cx, kind);
if (obj)
obj->capacity = js::gc::GetGCKindSlots(kind);
return obj;
}