Subj : Re: Calling non-existent object function crashes engine To : netscape.public.mozilla.jseng From : Syd Logan Date : Mon Sep 05 2005 05:12 pm John Bandhauer wrote: > Syd Logan wrote: > >> JSClass objectClass = { >> name.c_str(), JSCLASS_NEW_RESOLVE, >> JS_PropertyStub, JS_PropertyStub, >> JS_PropertyStub, JS_PropertyStub, >> JS_EnumerateStub, JS_ResolveStub, >> JS_ConvertStub, JS_FinalizeStub >> }; > > > > I'd say one mistake is in using JSCLASS_NEW_RESOLVE and passing > JS_ResolveStub. I believe that JSCLASS_NEW_RESOLVE tells the engine that > the resolve callback is of type JSNewResolveOp, but you are passing in a > callback of type JSResolveOp. That would be bad. Does sound bad, I'll give that a try. > > I'd also have to wonder if the name string you are passing is static > (name.c_str()) - the engine doesn't make a copy of it. As Brendan > pointed out, same story for the entire JSClass structure. Right. It's not static, it lives on the stack. But I have a place for both of these, thanks for pointing out the problem. > > You are either calling the wrong address if the JSClass* is not pointing > to data that doesn't change, or you are screwing up the stack on return > from JS_ResolveStub. > > > John. .