Subj : RE: Crash with release build JS and lazy standard classes To : netscape.public.mozilla.jseng From : Damian Slee Date : Tue Sep 28 2004 01:08 pm Encountered this again on another JSClass I have with lazy standard classes. This time it crashed in debug in my Resolve funtion. The passed **objp ptr is uninitialised. My Resolve function is being called from js_LookupProperty. Which I then relised I should be using JSCLASS_NEW_RESOLVE, which FIXED my problems. } else { /* * Old resolve always requires id re-lookup if obj owns * its scope after resolve returns. */ JS_UNLOCK_OBJ(cx, obj); ok = resolve(cx, obj, ID_TO_VALUE(id)); -------------------------------- JSBool CTest::Resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp) { // LAZY EVAL of STANDARD_CLASSES if ((flags & JSRESOLVE_ASSIGNING) == 0) { JSBool resolved; if (!JS_ResolveStandardClass(cx, obj, id, &resolved)) return JS_FALSE; if (resolved) { *objp = obj; return JS_TRUE; } } return JS_TRUE; } -----Original Message----- From: mozilla-jseng-admin@mozilla.org [mailto:mozilla-jseng-admin@mozilla.org] On Behalf Of Damian Slee Sent: Friday, 24 September 2004 3:12 PM To: mozilla-jseng@mozilla.org Subject: Crash with release build JS and lazy standard classes Not sure why this is happening, but when I use JS_NewObject or JS_DefineObject on my global that has enumerate and resolve hooks for lazy standary classes, it crashes in release version only. In JS_GC(). Works fine in debug. Change the hooks back to JS_EnumerateStub,JS_ResolveStub, and it doesn't crash. Am I missing something obvious? WinXP, VC6, JS 1.5rc6. using JS_THREADSAFE and libnspr. Tho this is crashing before any other threads start up. These are all static. JSClass CJSAppGlobal::Class = { "ASPglobal", 0/*JSCLASS_HAS_PRIVATE*/, JS_PropertyStub,JS_PropertyStub, JS_PropertyStub,JS_PropertyStub, /*CJSAppGlobal::Enumerate, (JSResolveOp) CJSAppGlobal::Resolve,*/ JS_EnumerateStub,JS_ResolveStub, JS_ConvertStub,JS_FinalizeStub }; JSBool CJSAppGlobal::Enumerate(JSContext *cx, JSObject *obj) { // LAZY_STANDARD_CLASSES return JS_EnumerateStandardClasses(cx, obj); } JSBool CJSAppGlobal::Resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags, JSObject **objp) { // LAZY_STANDARD_CLASSES if ((flags & JSRESOLVE_ASSIGNING) == 0) { JSBool resolved; if (!JS_ResolveStandardClass(cx, obj, id, &resolved)) return JS_FALSE; if (resolved) { *objp = obj; return JS_TRUE; } } return JS_TRUE; } ------------------------------------------------------------------------------------------ My context init sequence is; m_Runtime = JS_NewRuntime(0x1000*MAX_JS_CONTEXTS); .... // init a pool of 10 contexts m_Context[i] = JS_NewContext(m_Runtime, 0x1000); ... // succeeds JS_BeginRequest(m_Context[0]); m_appGlobal = JS_NewObject(m_Context[0], &CJSAppGlobal::Class, NULL, NULL); if (!m_appGlobal) return; JS_SetGlobalObject(m_Context[0], m_appGlobal); // +++++++++++++++++++++++++++++++++++++++++ // Crashes in JS_GC() later if this line is in. Seems to be independent of the class I'm creating. m_objApplication = JS_NewObject(m_Context[0], &CJSApplication::Class, NULL, NULL); // +++++++++++++++++++++++++++++++++++++++++ // ... had other code here to define as property of appGlobal. Still crashes with it out. // run application script + DOESN"T EXIST AT THE MOMENT, SO NO SCRIPT EXECUTES JSScript *appScript = JS_CompileFile(m_Context[0], m_appGlobal, m_strRoot+"\\global.asa"); if (appScript) { JSBool ok; jsval rval; ok = JS_ExecuteScript(m_Context[0], m_appGlobal, appScript, &rval); JS_DestroyScript(m_Context[0], appScript); } JS_EndRequest(m_Context[0]); JS_GC(m_Context[0]); // BOOM in release --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.756 / Virus Database: 506 - Release Date: 8/09/2004 _______________________________________________ mozilla-jseng mailing list mozilla-jseng@mozilla.org http://mail.mozilla.org/listinfo/mozilla-jseng --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.756 / Virus Database: 506 - Release Date: 8/09/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.769 / Virus Database: 516 - Release Date: 24/09/2004 .