You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is caused because the char arrays in ntl_wrap.cc are created using 'new' and free'd in Cython using 'free'. This has been fixed before (i.e. it is a regression) by replacing the 'new' calls with 'malloc's. malloc is the correct memory allocator here because the string is returned to C land.
Unfortunately at least in the code I'm looking at right now the array is freed using delete. Could you
retest. Here's all the relevant code (from ntl_wrap.cc, ntl.pyx and misc.pxi). There's no malloc or free involved:
def __repr__(self):
_sig_on
return string_delete(ZZ_pX_repr(self.x))
char* ZZ_pX_repr(struct ZZ_pX* x)
{
ostringstream instore;
instore << (*x);
int n = strlen(instore.str().data());
char* buf = new char[n+1];
strcpy(buf, instore.str().data());
return buf;
}
cdef object string_delete(char* s):
"""
Takes a char* allocated using C++ new, and converts it to a Python
string, then deletes the allocated memory. Also unsets the signal
handler, so you *must* call _sig_on right before calling this!
"""
_sig_off
t = str(s)
del_charstar(s)
return t
void del_charstar(char* a) {
delete a;
}
From Sage 2.8.3rc3:
Cheers,
Michael
Component: memleak
Issue created by migration from https://trac.sagemath.org/ticket/535
The text was updated successfully, but these errors were encountered: