SpiderMonkeys JS_EvaluateScript crashes

Started by
-1 comments, last by mike25025 18 years, 11 months ago
Edit: I solved the problem. The debug information was incompadible with my app. This is a very strange bug. Im using SpiderMonkey and when I run this code (copied from here)
/* get SpiderMonkey API declarations */
#include <jsapi.h>
/* EXIT_FAILURE and EXIT_SUCCESS */
#include <stdlib.h>  
/* strlen */
#include <string.h>

int
main(int argc, char** argv)
{
  /* pointer to our runtime object */
  JSRuntime *runtime=NULL;
  /* pointer to our context */
  JSContext *context=NULL;
  /* pointer to our global JavaScript object */
  JSObject  *global=NULL;

  /* script to run (should return 100) */
  char *script="var x=10;x*x;";
  /* JavaScript value to store the result of the script */
  jsval rval;
  
  /* create new runtime, new context, global object */
  if (    (!(runtime = JS_NewRuntime (1024L*1024L)))
       || (!(context = JS_NewContext (runtime, 8192)))
       || (!(global  = JS_NewObject  (context, NULL, NULL, NULL)))
     ) return EXIT_FAILURE;
  /* set global object of context and initialize standard ECMAScript
     objects (Math, Date, ...) within this global object scope */
  if (!JS_InitStandardClasses(context, global)) return EXIT_FAILURE;

  /* now we are ready to run our script */
  if (!JS_EvaluateScript(context, global,script, strlen(script),
			 "script", 1, &rval))
    return EXIT_FAILURE;
  /* check if the result is really 100 */
  if (!(JSVAL_IS_INT(rval)&&(JSVAL_TO_INT(rval)==100)))
    return EXIT_FAILURE;

  /* clean up */
  JS_DestroyContext(context);
  JS_DestroyRuntime(runtime);
  JS_ShutDown();

  return EXIT_SUCCESS;
}


I get "Unhandled exception at 0x1004367f in &#106avascriptApp.exe: 0xC0000005: Access violation reading location 0x00000014." on the line with JS_EvaluateScript. Any ideas why this could be happening? [Edited by - mike25025 on May 23, 2005 12:20:00 PM]

This topic is closed to new replies.

Advertisement