Subj : JS_NEWCONTEXT crashing To : netscape.public.mozilla.jseng From : raklar Date : Tue May 10 2005 08:46 am Hi, I've been trying to get XPConnect working in my application but I'm having problems getting the Javascript environment setup. I'm basically trying to use the code from the xpcshell sample. However when I call JS_NewContext it crashes at JS_LOCK_GC(rt); (rt->gcLock is NULL), however this works inside the xpcshell application. if I compile without the JS_THREADSAFE define it insteads asserts here: if (rt->state == JSRTS_DOWN) { JS_ASSERT(first); rt->state = JSRTS_LAUNCHING; break; } Anyway here is my code, any help is appreciated. Thanks, --Richard nsCOMPtr servMan; rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull); if (NS_FAILED(rv)) { printf("NS_InitXPCOM failed!\n"); return 1; } { nsCOMPtr registrar = do_QueryInterface(servMan); NS_ASSERTION(registrar, "Null nsIComponentRegistrar"); if (registrar) registrar->AutoRegister(nsnull); } nsCOMPtr rtsvc = do_GetService("@mozilla.org/js/xpc/RuntimeService;1"); // get the JSRuntime from the runtime svc if (!rtsvc) { printf("failed to get nsJSRuntimeService!\n"); return 1; } if (NS_FAILED(rtsvc->GetRuntime(&rt)) || !rt) { printf("failed to get JSRuntime from nsJSRuntimeService!\n"); return 1; } cx = JS_NewContext(rt, 8192); .