#13731: Fix libsingular memory management
--------------------------------------------------------------+-------------
Reporter: nbruin | Owner:
rlm
Type: defect | Status:
positive_review
Priority: major | Milestone:
sage-5.6
Component: memleak | Resolution:
Keywords: | Work issues:
Report Upstream: Fixed upstream, in a later stable release. | Reviewers:
Nils Bruin
Authors: Nils Bruin, Simon King | Merged in:
Dependencies: | Stopgaps:
--------------------------------------------------------------+-------------
Comment (by SimonKing):
Replying to [comment:119 nbruin]:
> Valgrind gives suspicious records for two of these tests:
>
> ...
>
> `sage -t "devel/sage/sage/schemes/toric/library.py"`:
>
> ...
>
> This looks like an off-by-one on an array of small primes. Indeed, in
>
> `sage/functions/prime_pi.pyx`:196
> {{{
> self.primes = <long*> sage_malloc(self.primeCount*sizeof(long))
> }}}
>
> whereas in
>
> `sage/functions/prime_pi.pyx`:263
> {{{
> for i in range(4, self.primeCount):
> if prime >= m_max: break
> x = N / prime
> if preTransition:
> if prime*prime <= x:
> sum -= self.prime_phi_small(x, prime) - i
> else:
> sum -= self.prime_phi_small(x) - i
> preTransition = False
> else:
> sum -= self.prime_phi_small(x) - i
> prime = self.primes[i + 1]
> return sum
> }}}
> The last line indeed gets `prime` from an unallocated address. However,
that value doesn't get used. So if this instruction succeeds I don't think
it'll do harm, but in extremely unlucky situations (when `self.primes` is
just at the edge of a page) this could lead to a segfault. The same thing
happens at other places in this file too.
>
> The sanitary thing is to allocate one "long" more. Then we'll only read
memory that's guaranteed to exist.
OK, but that wouldn't be an upstream bug, right?
Shall it then be dealt with on a different ticket, or shall we provide a
patch for the Sage library, in addition to the new Singular spkg?
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13731#comment:122>
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.