On Thursday, 19 April 2012 11:33:36 UTC+8, Stephen Montgomery-Smith wrote: > > I think I have found the problem with sympow. It is nothing to do with > elliptic curves. It is simply a malloc/free error. > > In util.c there is a function free_data, which frees TACKS[0]. TACKS[0] > is meant to be allocated in disk.c, but there are circumstances when > TACKS[0] is not allocated. > > See the attached patch. > > I am not going to submit it as a trac ticket until I have heard from > others. In general, how to different OS's react to "free(NULL)"? > FreeBSD does nothing, but maybe other OS's crash. In that case, the > code in free_data will also need to be changed to something like "if > (TACKS[0]!=NULL) free(TACKS[0]);". > MacOSX and Linux also don't do anything when free(NULL) is executed. A problem might arise when the default OS's free() is substituted by something else, e.g. a debugging version of malloc/free.
> But also, maybe there are other errors like this in sympow. I caught > this one by chance. > It would be great if you provided steps to reproduce this bug. It certainly is not caught by Sage doctests on MacOSX and Linux. > > --- sympow-1.018.1.p11/src/disk.c-orig 2012-04-19 02:33:51.000000000 +0000 > +++ sympow-1.018.1.p11/src/disk.c 2012-04-19 02:34:22.000000000 +0000 > @@ -39,7 +39,7 @@ > else if (((sp&3)==0) && CM_CASE) {if (2*ep==sp) S[3]='l'; else S[3]='h';} > else {if (2*ep==sp) S[3]='L'; else S[3]='H';} > if (HECKE && dv) {TACKS[which]=malloc(dv*sizeof(QD)); TACKON[which]=dv;} > - else if (dv<=sp/2) TACKON[which]=0; > + else if (dv<=sp/2) {TACKS[which]=NULL; TACKON[which]=0;} > else {TACKS[which]=malloc((dv-sp/2)*sizeof(QD)); TACKON[which]=dv-sp/2;} > S[4]=0; F=fopen("datafiles/param_data","r"); strcpy(U,S); > if (ANAL_RANK) {if (dv>0) U[0]='A'; else U[0]='m';} > > -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org