Opened 9 years ago

Closed 9 years ago

# memory corruption by nested statements in ASSUME?

Reported by: Owned by: kroeker@… somebody major 4-1-0 and higher dontKnow 4-0-0 memory corruption ASSUME

### Description

I guess, ASSUME statements or intermediate results without assignment may corrupt memory; here is an example:

```
LIB("primdecint.lib");

proc testPrimaryZ(list pr, ideal k)
"USAGE:   testPrimaryZ(pr,k); pr a list, k an ideal  over integers
RETURN:  int, 1 if the intersection of the ideals in pr is k, 0 if not
"
{
int i;
pr=Primdec::reconvList(pr);
ideal j=pr;
ideal tmpj ;
for (i=2;i<=size(pr) div 2;i++)
{
ASSUME(0, (2*i-1) >0 && (2*i-1)<=size(pr));
tmpj=intersectZ(j,pr[2*i-1]);
ASSUME(0, idealsEqual(  tmpj,   intersect(    j,pr[2*i-1]     )  ));
j = tmpj;
}
return(Primdec::idealsEqual(j,k));
}

ring rng = integer,(xj,xp),dp;

ideal I= 3*xj^2,2*xp*xj;
def pdec=primdecZ(I);

testPrimaryZ(pdec,I);
```

output:

```. testPrimaryZ(pdec,I);
occured at:  ??
occured for addr:0x7f656df7cb50 size:176 allocated at  ??
occured at:  ??
occured for addr:0x7f656df7bee0 size:176 allocated at  ??
occured at:  ??
occured for addr:0x7f656e044300 size:176 allocated at  ??
```

while it seems there are no problems with a slightly modified one:

```LIB("primdecint.lib");

proc testPrimaryZ(list pr, ideal k)
"USAGE:   testPrimaryZ(pr,k); pr a list, k an ideal over integers
RETURN:  int, 1 if the intersection of the ideals in pr is k, 0 if not
"
{
int i;
pr=Primdec::reconvList(pr);
ideal j=pr;
ideal tmpj ;
int tstRes;
for (i=2;i<=size(pr) div 2;i++)
{
ASSUME(0, (2*i-1) >0 && (2*i-1)<=size(pr));
tmpj=intersectZ(j,pr[2*i-1]);
tstRes = idealsEqual(tmpj,  intersect(  j,pr[2*i-1]  )) ;
ASSUME(0, tstRes  );
j = tmpj;
}
return(Primdec::idealsEqual(j,k));
}

ring rng = integer,(xj,xp),dp;

ideal I= 3*xj^2,2*xp*xj;
def pdec=primdecZ(I);

testPrimaryZ(pdec,I);
```

### comment:1 Changed 9 years ago by hannes

Resolution: → fixed new → closed
Note: See TracTickets for help on using tickets.