Bug#964848: sagemath: Integer objects leak memory
Uoti Urpala
uoti.urpala at pp1.inet.fi
Sat Jul 11 19:04:31 BST 2020
I investigated this more, and came to the conclusion that Sage is
incompatible with libgmp 6.2 due to the following commit:
https://gmplib.org/repo/gmp-6.2/rev/299ec6187305
This invalidates the assumptions Sage's rings/integer.pyx makes about
libgmp internals. The "global_dummy_Integer" object created there
without an explicit value will now be created using libgmp's new lazy
allocation, and Sage's fast_tp_new() forcibly changing the _mp_d member
of such an object to a new allocation will lead to an inconsistent
state (allocation size still set to 0, but non-dummy pointer set). This
causes libgmp to disregard the existing pointer and leak the memory
when setting a new value in the object.
I believe (haven't tested though) that a quick workaround would be to
change
global_dummy_Integer = Integer()
to
global_dummy_Integer = Integer(1)
which would force the global default object to use non-lazy allocation.
More information about the debian-science-maintainers
mailing list