Opened 10 years ago

Closed 10 years ago

#573 closed bug (fixed)

memory corruption by nested statements in ASSUME?

Reported by: kroeker@… Owned by: somebody
Priority: major Milestone: 4-1-0 and higher
Component: dontKnow Version: 4-0-0
Keywords: memory corruption ASSUME Cc:

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[1];
   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);
***omError_FalseAddrOrMemoryCorrupted: addr not as returned by omalloc or memory corrupted
 occured at:  ??
 occured for addr:0x7f656df7cb50 size:176 allocated at  ??
***omError_FalseAddrOrMemoryCorrupted: addr not as returned by omalloc or memory corrupted
 occured at:  ??
 occured for addr:0x7f656df7bee0 size:176 allocated at  ??
***omError_FalseAddrOrMemoryCorrupted: addr not as returned by omalloc or memory corrupted
 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[1];
   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);

Change History (1)

comment:1 Changed 10 years ago by hannes

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.