Jump to content
  • Advertisement
Sign in to follow this  
mike25025

SpiderMonkeys JS_EvaluateScript crashes

This topic is 4749 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 javascriptApp.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]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!