Subj : differnce btwn JS_AddRoot and JS_LockGCThing??? To : netscape.public.mozilla.jseng From : Aaron Reed Date : Wed May 26 2004 04:02 pm Hey, Ok, we compile a function using scriptContext->CompileFunction and then we want to prevent the returned funcObj from being garbage collected. If we us JS_LockGCThing, it is protected just fine. If we use JS_AddRoot (since JS_LockGCThing is deprecated), this throws an assertion in gc_root_marker. gc_root_marker is checking to see if the item was allocated from the gcArenaPool. However what it is checking isn't the object that we rooted, but rather the return value from JSVAL_TO_GCTHING(v). And it isn't marking the obj that we rooted either, it is marking the return value from JSVAL_TO_GCTHING(v). So why the difference? Why doesn't gc_lock_marker care about the JSVAL? Should we just go ahead and use JS_LockGCThing? If we should use JS_AddRoot, how do we ensure that we are marking the right thing? Thanks for your help, --Aaron .