c++ - spidermonkey 1.8.5 crashes in debug mode -


i using spidermonkey 1.8.5 in application. application crashes when use debug js library. building library following options: --enable-debug --disable-optimize --enable-threadsafe

crash pointing here: assertion failure: (cx)->thread->data.requestdepth || (cx)->thread == (cx)->runtime->gcthread, @ ../../src/jsapi.cpp

here sample program

/* include jsapi header file access spidermonkey. */ #include "jsapi.h"    /* class of global object. */ static jsclass global_class = {     "global", jsclass_global_flags,     js_propertystub, js_propertystub, js_propertystub, js_strictpropertystub,     js_enumeratestub, js_resolvestub, js_convertstub, js_finalizestub,     jsclass_no_optional_members };  /* error reporter callback. */ void reporterror(jscontext *cx, const char *message, jserrorreport *report) {     fprintf(stderr, "%s:%u:%s\n",             report->filename ? report->filename : "<no filename=\"filename\">",             (unsigned int) report->lineno,             message); }  int main(int argc, const char *argv[]) {     /* jsapi variables. */     jsruntime *rt;     jscontext *cx;     jsobject  *global;     printf("started\n");     /* create js runtime. need @ least 1 runtime per process. */     rt = js_newruntime(8 * 1024 * 1024);      if (rt == null)         return 1;      /*      * create context. need context per thread.      * note program not multi-threaded.      */     cx = js_newcontext(rt, 8192);     if (cx == null)         return 1;      js_seterrorreporter(cx, reporterror);      /*      * create global object in new compartment.      * need global object per context.      */     global = js_newcompartmentandglobalobject(cx, &global_class, null);     if (global == null)         return 1;      /*      * populate global object standard javascript      * function , object classes, such object, array, date.      */     if (!js_initstandardclasses(cx, global))         return 1;      /* application code here. may include jsapi calls      * create own custom javascript objects , run scripts.      *      * following example code creates literal javascript script,      * evaluates it, , prints result stdout.      *      * errors conventionally saved in jsbool variable named ok.      */     char *script = "'hello ' + 'world!'";     jsval rval;     jsstring *str;     jsbool ok;     const char *filename = "noname";     uintn lineno = 0;      ok = js_evaluatescript(cx, global, script, strlen(script),                            filename, lineno, &rval);     if (rval == null | rval == js_false)         return 1;      str = js_valuetostring(cx, rval);     printf("%s\n", js_encodestring(cx, str));      /* end of application code */      /* clean things , shut down spidermonkey. */     js_destroycontext(cx);     js_destroyruntime(rt);     js_shutdown();     return 0; } 

if building in release mode program works fine. problem debug mode. missing here?

insert js_beginrequest(cx); before js_newcompartmentandglobalobject call.

insert js_endrequest(cx); before call js_destroycontext.

most jsapi functions require request. (i'm not sure why. original reason threads had multithreading, each jsruntime single-threaded now.)

the debug build of spidermonkey includes assertions check api usage in ways release mode can't. see debug-only assertions again. recommend developing against debug build, because assertions indicate real problems.

the next spidermonkey release coming soon: https://bugzilla.mozilla.org/show_bug.cgi?id=735599#c54


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -