#13731: Fix libsingular memory management
---------------------------+------------------------------------------------
       Reporter:  nbruin   |         Owner:  rlm     
           Type:  defect   |        Status:  new     
       Priority:  major    |     Milestone:  sage-5.6
      Component:  memleak  |    Resolution:          
       Keywords:           |   Work issues:          
Report Upstream:  N/A      |     Reviewers:          
        Authors:           |     Merged in:          
   Dependencies:           |      Stopgaps:          
---------------------------+------------------------------------------------

Comment (by SimonKing):

 OK, the error occurs in the function `poly gnc_mm_Mult_nn(int *F0, int
 *G0, const ring r)`, whose definition in `kernel/gring.cc` starts at line
 463.

 I inserted some print statements, and found the crash occurs in this chunk
 of code:
 {{{
   if (iF<=jG)
     /* i.e. no mixed exp_num , MERGE case */
   {
     p_MemAdd_LengthGeneral(F, G, ExpSize/sizeof(long));
     p_SetExpV(out,F,r);
     p_Setm(out,r);
     //    omFreeSize((ADDRESS)F,ExpSize);
     printf("second freeT F,rN\n");
     freeT(F,rN);
     printf("second freeT G,rN\n");
     freeT(G,rN);
     printf("second return out\n");
     return(out);
   }
 }}}
 The last line printed is `second freeT F,rN`. Hence, F seems to be
 corrupted. Here is ho F is created:
 {{{
   int *F=(int *)omAlloc0((rN+1)*sizeof(int));
   int *G=(int *)omAlloc0((rN+1)*sizeof(int));

   memcpy(F, F0,(rN+1)*sizeof(int));
   // pExpVectorCopy(F,F0);
   memcpy(G, G0,(rN+1)*sizeof(int));
   //  pExpVectorCopy(G,G0);
   F[0]=0; /* important for p_MemAdd */
   G[0]=0;
 }}}

 Is it a problem that `omAlloc0` is explicitly called? Or is it just a
 macro, and actually defaults to malloc with your spkg?

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13731#comment:27>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to