[perl #36852] [PATCH] imcc/main.c - to fix segmentation fault on "-E (--pre-process-only)" option

0 views
Skip to first unread message

Tom @ Nekomimists . Ddo . Jp

unread,
Aug 9, 2005, 10:34:50 PM8/9/05
to bugs-bi...@rt.perl.org
# New Ticket Created by t...@nekomimists.ddo.jp
# 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...

main.c.patch

Leopold Toetsch

unread,
Aug 11, 2005, 7:43:59 AM8/11/05
to perl6-i...@perl.org, bugs-bi...@netlabs.develooper.com
t...@nekomimists.ddo.jp (via RT) wrote:

> Objective:
> Parrot stops for segmentation fault when "-E (--pre-process-only)"
> option is specified.
> This patch fixes this bug.

Thanks, applied -r8914

(Please not that the preprocessor is currently not uptodate and doesn't
process all tokens correctly)

leo

Reply all
Reply to author
Forward
0 new messages