Advertisement Jump to content
Sign in to follow this  

SpiderMonkeys JS_EvaluateScript crashes

This topic is 4993 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>
#include <stdlib.h>  
/* strlen */
#include <string.h>

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 */

  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
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!