Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

readline problem

4 views
Skip to first unread message

Will Coleda

unread,
Apr 28, 2003, 1:24:57 PM4/28/03
to perl6-i...@perl.org
I dusted off my tcl work in progress this weekend, and tried it with a
fresh cvs snapshot: I started getting bus errors. Aside from lots of print
statements, is there any kind of debugging support at this time?

I managed to reduce the problem to the following. Digging through the docs
to make sure the syntax didn't change, I see that readline is marked with
the EVIL flag. =-)

I'm running on OSX10.2.5

%cat hello.tcl
This is fun
%cat foo.imc
sub _MAIN
.local string filename
.local string line
.local int fd
filename = "hello.tcl"
open fd,filename
readline line,fd
end
% ../../imcc/imcc -o foo.pasm foo.imc
% cat foo.pasm
_MAIN:
set S0, "hello.tcl"
open I0, S0
readline S0, I0
% perl -I../../../lib ../../../assemble.pl foo.pasm > foo.pbc
% ../../../parrot foo.pbc
Bus Error


.. That isn't my original hello.tcl file, but this one's shorter and
produces the same bus error.
=-)

---------------------------------------------
This message was sent using Road Runner's Web-based
e-mail.

Will Coleda

unread,
Apr 28, 2003, 2:14:53 PM4/28/03
to Will Coleda, perl6-i...@perl.org
Whoops. Should have thought of this earlier. Here's a gdb stacktrace:

#0 0x9000d38c in fgets ()
#1 0x00091fc0 in cg_core (cur_op=0x57904c, interpreter=0x513400) at
core.ops:143
#2 0x0004fda4 in runops_cgoto_core (interpreter=0x513400,
pc=0x57904c) at runops_cores.c:52
#3 0x00002e58 in runops_int (interpreter=0x513400, offset=0) at
interpreter.c:387
#4 0x00002edc in runops (interpreter=0x513400, offset=0) at
interpreter.c:403
#5 0x00091388 in Parrot_runcode (interpreter=0x513400, argc=1,
argv=0xbffffe2c) at embed.c:326
#6 0x001015e8 in main (argc=1, argv=0xbffffe2c) at test_main.c:51
#7 0x00001ed8 in _start (argc=2, argv=0xbffffe28, envp=0xbffffe34) at
/SourceCache/Csu/Csu-45/crt.c:267
#8 0x00001d58 in start ()


> I dusted off my tcl work in progress this weekend, and tried it with
a
> fresh cvs snapshot: I started getting bus errors. Aside from lots of
print
> statements, is there any kind of debugging support at this time?
>
> I managed to reduce the problem to the following. Digging through
the docs
> to make sure the syntax didn't change, I see that readline is marked
with
> the EVIL flag. =-)
>
> I'm running on OSX10.2.5
>
> %cat hello.tcl
> This is fun
> %cat foo.imc

> .sub _MAIN


> .local string filename
> .local string line
> .local int fd
> filename = "hello.tcl"
> open fd,filename
> readline line,fd

> .end


> % ../../imcc/imcc -o foo.pasm foo.imc
> % cat foo.pasm
> _MAIN:
> set S0, "hello.tcl"
> open I0, S0
> readline S0, I0
> % perl -I../../../lib ../../../assemble.pl foo.pasm > foo.pbc
> % ../../../parrot foo.pbc
> Bus Error
>
>

> ... That isn't my original hello.tcl file, but this one's shorter

Benjamin Goldberg

unread,
Apr 28, 2003, 7:22:57 PM4/28/03
to perl6-i...@perl.org

Will Coleda wrote:
>
> Whoops. Should have thought of this earlier. Here's a gdb stacktrace:
>
> #0 0x9000d38c in fgets ()
> #1 0x00091fc0 in cg_core (cur_op=0x57904c, interpreter=0x513400) at
> core.ops:143

Lines 142 and 143 of core.ops are:

memset(($1)->strstart, 0, 65535);
fgets(($1)->strstart, 65534, file);

How can the fgets core-dump, if the memset succeeded?

--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}

Benjamin Goldberg

unread,
Apr 28, 2003, 10:17:24 PM4/28/03
to perl6-i...@perl.org

Benjamin Goldberg wrote:
>
> Will Coleda wrote:
> >
> > Whoops. Should have thought of this earlier. Here's a gdb stacktrace:
> >
> > #0 0x9000d38c in fgets ()
> > #1 0x00091fc0 in cg_core (cur_op=0x57904c, interpreter=0x513400) at
> > core.ops:143
>
> Lines 142 and 143 of core.ops are:
>
> memset(($1)->strstart, 0, 65535);
> fgets(($1)->strstart, 65534, file);
>
> How can the fgets core-dump, if the memset succeeded?

Oups, nevermind -- I just realized that the core dump isn't because of
fiddling with ($1)->strstart, it's because of the 'file' variable.

The 'open' op (from io.ops) is producing a filedescriptor (an int), and
then you are passing it to a function that naively uses it as a FILE*
object (a pointer).

0 new messages