# New Ticket Created by [EMAIL PROTECTED] # Please include the string: [perl #36852] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=36852 >
Objective: Parrot stops for segmentation fault when "-E (--pre-process-only)" option is specified. This patch fixes this bug. Detail: The bug is following: ~/projects/parrot$ cat macro.pir .macro hello(name) print "Hello," print .name print "!\n" .endm .sub main .hello("world") .hello("Parrot") .end ~/projects/parrot$ gdb --args ./parrot -E macro.pir GNU gdb 6.3-debian Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-linux"...Using host libthread_db library "/lib/libthread_db.so.1". (gdb) run Starting program: /home/tom/projects/parrot/parrot -E macro.pir [Thread debugging using libthread_db enabled] [New Thread 16384 (LWP 26420)] [New Thread 32769 (LWP 26421)] [New Thread 16386 (LWP 26422)] [New Thread 32771 (LWP 26423)] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 26420)] 0x0813ac12 in yylex (valp=0xbffffa50, interp=0x826fdc8) at imcc.l:122 122 if (frames->s.pasm_file && YYSTATE == INITIAL && !in_pod) { (gdb) p frames $1 = (struct macro_frame_t *) 0x0 (gdb) list 117 /* for emacs "*/ 118 if (expect_pasm == 1 && !in_pod) { 119 expect_pasm = 2; 120 BEGIN(emit); 121 } 122 if (frames->s.pasm_file && YYSTATE == INITIAL && !in_pod) { 123 if (0) 124 yy_top_state(); /* silent warning */ 125 if (frames->s.pasm_file == 1) { 126 BEGIN(emit); (gdb) where #0 0x0813ac12 in yylex (valp=0xbffffa50, interp=0x826fdc8) at imcc.l:122 #1 0x080847f6 in do_pre_process (interp=0x826fdc8) at imcc/main.c:371 #2 0x08084ef4 in main (argc=1, argv=0xbffffb0c) at imcc/main.c:502 (gdb) quit The program is running. Exit anyway? (y or n) y I guess that a variable "frames" in imcc/imclexer.c is prepared before yylex() is called, likely attached patch. Frankly speaking, I don't understand imcc/imclexer.c much, so you can probably take better ways than this patch...
--- imcc/main.c.orig 2005-08-10 10:31:31.000000000 +0900 +++ imcc/main.c 2005-08-10 10:55:00.000000000 +0900 @@ -368,6 +368,7 @@ int c; YYSTYPE val; + IMCC_push_parser_state(interp); while ( (c = yylex(&val, interp)) ) { switch (c) { case EMIT: printf(".emit\n"); break;