[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

for loops broken in 0.5.10




I guess this is must be a known bug. I get the following segfault when
using a for loop.

#0  0x805bb4e in iter_operator_pre (ctx=0x80d00c8) at eval.c:3779
#1  0x805c0c9 in iter_eval_etree (ctx=0x80d00c8) at eval.c:3980
#2  0x805c3e4 in eval_etree (ctx=0x80d00c8, etree=0x80d0050) at eval.c:4060
#3  0x80525ff in runexp (exp=0x80d00b0) at calc.c:1302
#4  0x805267d in evalexp_parsed (parsed=0x80d00b0, gelo=0x80a7f38, 
    prefix=0x808a374 "= ", pretty=1) at calc.c:1326
#5  0x80604aa in main (argc=1, argv=0xbffffadc) at genius.c:336

The cause for this is that n->comp->args is invalid.

(gdb) list
3774                    break;
3775    
3776            case E_FOR_CONS:
3777            case E_FORBY_CONS:
3778                    GE_PUSH_STACK(ctx,n,GE_POST);
3779                    iter_push_args_no_last(ctx,n->comp.args->any.next);
3780                    break;
3781    
3782            case E_FORIN_CONS:
3783                    GE_PUSH_STACK(ctx,n,GE_POST);
(gdb) print ctx
$1 = (struct _GelCtx *) 0x80d00c8
(gdb) print n
$2 = (union _GelETree *) 0x80d1620
(gdb) print n->comp.args
$3 = (union _GelETree *) 0x4
(gdb) print n->comp
$4 = {type = OPERATOR_NODE, next = 0x0, nargs = 19, args = 0x4, 
  comp = 0x80d1638}
(gdb) print *n
$5 = {type = OPERATOR_NODE, any = {type = OPERATOR_NODE, next = 0x0}, val = {
    type = OPERATOR_NODE, next = 0x0, value = {{type = 19, r = 0x4, 
        i = 0x80d1638}}}, mat = {type = OPERATOR_NODE, next = 0x0, 
    matrix = 0x13, quoted = 0}, set = {type = OPERATOR_NODE, next = 0x0, 
    items = 0x13, multiset = 0}, op = {type = OPERATOR_NODE, next = 0x0, 
    oper = 19, nargs = 4, args = 0x80d1638}, id = {type = OPERATOR_NODE, 
    next = 0x0, id = 0x13}, str = {type = OPERATOR_NODE, next = 0x0, 
    str = 0x13 <Address 0x13 out of bounds>}, func = {type = OPERATOR_NODE, 
    next = 0x0, func = 0x13}, comp = {type = OPERATOR_NODE, next = 0x0, 
    nargs = 19, args = 0x4, comp = 0x80d1638}, ut = {type = OPERATOR_NODE, 
    next = 0x0, ttype = 19, data = 0x4}, row = {type = OPERATOR_NODE, 
    next = 0x0, nargs = 19, args = 0x4}, sp = {type = OPERATOR_NODE, 
    next = 0x0, arg = 0x13}}

I am using glibc 2.2 and gcc 2.95.2 on a homegrown Linux 2.4 AMD K6-2
(i586) system. I compiled with CFLAGS="-ggdb -pipe" CXXFLAGS="-ggdb
-pipe" to get the debug trace.

What I typed:

Genius 0.5.10
Copyright (c) 1997,1998,1999 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.

genius> Prime
= (`(n)=(((((x=1);(for loop = 1 to n do (x=(NextPrime(x)))));(return x));(nu...
genius> Prime(2);
Segmentation fault

-- 

	http://www.penguinpowered.com/~vii