Subj : Re: problems with error reporting To : Brendan Eich From : Silviu Trasca Date : Wed Jun 22 2005 12:17 pm This is a multi-part message in MIME format. --------------040300080104080601050001 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sorry, I was not aware that the JS stuff was compiled without debug information. Here it again built with "BUILD_OPT=true" commeted out and "JS_THREADSAFE=true" added in js/Makefile.ref, js/fdlibm/Makefile.ref : [silviu@silviu js]$ valgrind ./js ==13904== Memcheck, a memory error detector for x86-linux. ==13904== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al. ==13904== Using valgrind-2.4.0, a program supervision framework for x86-linux. ==13904== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al. ==13904== For more details, rerun with: -v ==13904== js>MM_preloadImages('/images/nav_catalog_f2.gif','/images/nav_new_f2.gif','/images/nav_acad_f2.gif','/images/nav_about_f2.gif','/images/top_contact_on.gif,'/images/top_booksellers_on.gif,'/images/top_map_on.gif,'/images/top_cart_on.gif,'/images/top_home_on.gif); 1: SyntaxError: unterminated string literal: 1: if); 1: ......==13904== Invalid read of size 1 ==13904== at 0x804C216: my_ErrorReporter (js.c:1903) ==13904== by 0x805D66A: js_ReportErrorAgain (jscntxt.c:674) ==13904== by 0x8079493: js_ReportUncaughtException (jsexn.c:1073) ==13904== by 0x8054965: JS_CompileUCScriptForPrincipals (jsapi.c:3104) ==13904== by 0x80548E6: JS_CompileUCScript (jsapi.c:3082) ==13904== by 0x8054837: JS_CompileScript (jsapi.c:3052) ==13904== by 0x80496F1: Process (js.c:382) ==13904== by 0x8049CE6: ProcessArgs (js.c:568) ==13904== by 0x804C77A: main (js.c:2426) ==13904== Address 0x1B93D2EE is 0 bytes after a block of size 6 alloc'd ==13904== at 0x1B903298: malloc (vg_replace_malloc.c:130) ==13904== by 0x80CFAE2: js_DeflateString (jsstr.c:2805) ==13904== by 0x80CFE75: js_GetStringBytes (jsstr.c:2881) ==13904== by 0x8055ABE: JS_GetStringBytes (jsapi.c:3782) ==13904== by 0x80C095E: js_ReportCompileErrorNumber (jsscan.c:561) ==13904== by 0x80C220F: js_GetToken (jsscan.c:939) ==13904== by 0x80B3896: UnaryExpr (jsparse.c:2564) ==13904== by 0x80B359F: MulExpr (jsparse.c:2481) ==13904== by 0x80B34D8: AddExpr (jsparse.c:2463) ==13904== by 0x80B344A: ShiftExpr (jsparse.c:2448) ==13904== by 0x80B3359: RelExpr (jsparse.c:2416) ==13904== by 0x80B32B3: EqExpr (jsparse.c:2392) .......... Brendan Eich wrote: > Silviu Trasca wrote: > >> Hi, >> I'm embedding SpiderMonkey in my app and have problems (invalid >> memory reads) with error reporting for lines of code greater than 256 >> characters. I'm using an error handler similar with the one in >> js/js.c . I was able to reproduce the problem with "js" shell only >> (see the valgrind output bellow). SpiderMonkey is compiled in thread >> safe mode, on FC3. >> >> Thanks, >> Silviu >> >> >> [silviu@home-tx0275arsq js]$ valgrind --tool=memcheck ./js >> ==10403== Memcheck, a memory error detector for x86-linux. >> ==10403== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et >> al. >> ==10403== Using valgrind-2.2.0, a program supervision framework for >> x86-linux. >> ==10403== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et >> al. >> ==10403== For more details, rerun with: -v >> ==10403== >> js>MM_preloadImages('/images/nav_catalog_f2.gif','/images/nav_new_f2.gif','/images/nav_acad_f2.gif','/images/nav_about_f2.gif','/images/top_contact_on.gif,'/images/top_booksellers_on.gif,'/images/top_map_on.gif,'/images/top_cart_on.gif,'/images/top_home_on.gif); >> >> 1: SyntaxError: unterminated string literal: >> 1: if); >> 1: ......==10403== Invalid read of size 1 >> ==10403== at 0x804A880: my_ErrorReporter (in >> /home/silviu/projects/js/js) > > > > Exactly what line in my_ErrorReporter? I have single-stepped through > in gdb and see no invalid loads (memory reads). > > /be > > >> ==10403== by 0x8077AC4: js_ReportUncaughtException (in >> /home/silviu/projects/js/js) >> ==10403== by 0x804E563: JS_CompileScript (in >> /home/silviu/projects/js/js) >> ==10403== by 0x8049407: Process (in /home/silviu/projects/js/js) >> ==10403== Address 0x1B969986 is 0 bytes after a block of size 6 alloc'd >> ==10403== at 0x1B902A90: malloc (vg_replace_malloc.c:131) >> ==10403== by 0x80B9F90: js_GetStringBytes (in >> /home/silviu/projects/js/js) >> ==10403== by 0x804F45D: JS_GetStringBytes (in >> /home/silviu/projects/js/js) >> ==10403== by 0x80ABEB4: js_ReportCompileErrorNumber (in >> /home/silviu/projects/js/js) >> ...................................................................................................................................................................................................................................^ >> >> js> >> --------------040300080104080601050001 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sorry, I was not aware that the JS stuff was compiled without debug information. Here it again built with "BUILD_OPT=true" commeted out and "JS_THREADSAFE=true" added in js/Makefile.ref, js/fdlibm/Makefile.ref :

[silviu@silviu js]$ valgrind ./js
==13904== Memcheck, a memory error detector for x86-linux.
==13904== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==13904== Using valgrind-2.4.0, a program supervision framework for x86-linux.
==13904== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==13904== For more details, rerun with: -v
==13904==
js>MM_preloadImages('/images/nav_catalog_f2.gif','/images/nav_new_f2.gif','/images/nav_acad_f2.gif','/images/nav_about_f2.gif','/images/top_contact_on.gif,'/images/top_booksellers_on.gif,'/images/top_map_on.gif,'/images/top_cart_on.gif,'/images/top_home_on.gif);
1: SyntaxError: unterminated string literal:
1: if);
1: ......==13904== Invalid read of size 1
==13904==    at 0x804C216: my_ErrorReporter (js.c:1903)
==13904==    by 0x805D66A: js_ReportErrorAgain (jscntxt.c:674)
==13904==    by 0x8079493: js_ReportUncaughtException (jsexn.c:1073)
==13904==    by 0x8054965: JS_CompileUCScriptForPrincipals (jsapi.c:3104)
==13904==    by 0x80548E6: JS_CompileUCScript (jsapi.c:3082)
==13904==    by 0x8054837: JS_CompileScript (jsapi.c:3052)
==13904==    by 0x80496F1: Process (js.c:382)
==13904==    by 0x8049CE6: ProcessArgs (js.c:568)
==13904==    by 0x804C77A: main (js.c:2426)
==13904==  Address 0x1B93D2EE is 0 bytes after a block of size 6 alloc'd
==13904==    at 0x1B903298: malloc (vg_replace_malloc.c:130)
==13904==    by 0x80CFAE2: js_DeflateString (jsstr.c:2805)
==13904==    by 0x80CFE75: js_GetStringBytes (jsstr.c:2881)
==13904==    by 0x8055ABE: JS_GetStringBytes (jsapi.c:3782)
==13904==    by 0x80C095E: js_ReportCompileErrorNumber (jsscan.c:561)
==13904==    by 0x80C220F: js_GetToken (jsscan.c:939)
==13904==    by 0x80B3896: UnaryExpr (jsparse.c:2564)
==13904==    by 0x80B359F: MulExpr (jsparse.c:2481)
==13904==    by 0x80B34D8: AddExpr (jsparse.c:2463)
==13904==    by 0x80B344A: ShiftExpr (jsparse.c:2448)
==13904==    by 0x80B3359: RelExpr (jsparse.c:2416)
==13904==    by 0x80B32B3: EqExpr (jsparse.c:2392)
..........


Brendan Eich wrote:
Silviu Trasca wrote:
Hi,
I'm embedding SpiderMonkey in my app and have problems (invalid memory reads) with error reporting for lines of code greater than 256 characters. I'm using an error  handler similar with the one in js/js.c .. I was able to reproduce the problem with "js" shell only (see the valgrind output bellow). SpiderMonkey is compiled in thread safe mode, on FC3.

Thanks,
Silviu


[silviu@home-tx0275arsq js]$ valgrind --tool=memcheck ./js
==10403== Memcheck, a memory error detector for x86-linux.
==10403== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al.
==10403== Using valgrind-2.2.0, a program supervision framework for x86-linux.
==10403== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al.
==10403== For more details, rerun with: -v
==10403==
js>MM_preloadImages('/images/nav_catalog_f2.gif','/images/nav_new_f2.gif','/images/nav_acad_f2.gif','/images/nav_about_f2.gif','/images/top_contact_on.gif,'/images/top_booksellers_on.gif,'/images/top_map_on.gif,'/images/top_cart_on.gif,'/images/top_home_on.gif);
1: SyntaxError: unterminated string literal:
1: if);
1: ......==10403== Invalid read of size 1
==10403== at 0x804A880: my_ErrorReporter (in /home/silviu/projects/js/js)


Exactly what line in my_ErrorReporter?  I have single-stepped through in gdb and see no invalid loads (memory reads).

/be


==10403== by 0x8077AC4: js_ReportUncaughtException (in /home/silviu/projects/js/js)
==10403== by 0x804E563: JS_CompileScript (in /home/silviu/projects/js/js)
==10403== by 0x8049407: Process (in /home/silviu/projects/js/js)
==10403== Address 0x1B969986 is 0 bytes after a block of size 6 alloc'd
==10403== at 0x1B902A90: malloc (vg_replace_malloc.c:131)
==10403== by 0x80B9F90: js_GetStringBytes (in /home/silviu/projects/js/js)
==10403== by 0x804F45D: JS_GetStringBytes (in /home/silviu/projects/js/js)
==10403== by 0x80ABEB4: js_ReportCompileErrorNumber (in
/home/silviu/projects/js/js)
....................................................................................................................................................................................................................................^
js>


--------------040300080104080601050001-- .