#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:  Reported upstream. Developers acknowledge bug.  |     
Reviewers:          
        Authors:                                                  |     Merged 
in:          
   Dependencies:                                                  |      
Stopgaps:          
------------------------------------------------------------------+---------

Comment (by nbruin):

 > {{{
 > ==30816== Conditional jump or move depends on uninitialised value(s)
 > ==30816==    at 0x26942A01: hGetmem(int, int**, monrec*)
 > }}}
 I think this one is benign, because rewriting the code to the functionally
 equivalent

 `hutil.cc:1020:`
 {{{#!diff
 scfmon hGetmem(int lm, scfmon old, monp monmem)
 {
    scfmon x = monmem->mo;
    int  lx = monmem->a;
    if ((x==NULL) || (lm > lx))
    {
 -    if ((x!=NULL)&&(lx>0)) omFreeSize((ADDRESS)x, lx * sizeof(scmon));
 +    if (x!=NULL) if (lx>0) omFreeSize((ADDRESS)x, lx * sizeof(scmon));
      monmem->mo = x = (scfmon)omAlloc(lm * sizeof(scmon));
      monmem->a = lm;
    }
    memcpy(x, old, lm * sizeof(scmon));
    return x;
 }
 }}}
 makes the reports go away. I guess gcc optimizes out the shortcutting
 because it's not a benefit here and valgrind doesn't see through the fact
 that the undefined value doesn't influence the outcome.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13731#comment:42>
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