Skip to content

Valgrind reports memory leak due to FactArg #507

@jodavies

Description

@jodavies

In the following example, valgrind reports a leak:

64 bytes in 1 blocks are definitely lost in loss record 52 of 161
   at 0x4849013: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x1CA6A2: allocate (new_allocator.h:127)
   by 0x1CA6A2: allocate (alloc_traits.h:464)
   by 0x1CA6A2: _M_allocate (stl_vector.h:346)
   by 0x1CA6A2: _M_create_storage (stl_vector.h:361)
   by 0x1CA6A2: _Vector_base (stl_vector.h:305)
   by 0x1CA6A2: vector (stl_vector.h:524)
   by 0x1CA6A2: polyfact::Berlekamp_find_factors(poly const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&) (polyfact.cc:1270)
   by 0x1CC566: polyfact::factorize_squarefree(poly const&, std::vector<int, std::allocator<int> > const&) (polyfact.cc:1485)
   by 0x1CE1F0: polyfact::factorize(poly const&) (polyfact.cc:1673)
   by 0x1DBC73: poly_factorize(int*, int*, bool, bool) (polywrap.cc:946)
   by 0x1DC1E8: poly_factorize_argument (polywrap.cc:1062)
   by 0x117E11: ArgFactorize (argument.c:2255)
   by 0x11B7A7: execarg (argument.c:1121)
   by 0x1F4AA9: Generator (proces.c:3616)
   by 0x1F5946: Generator (proces.c:4048)
   by 0x1F5DAA: Generator (proces.c:4216)
   by 0x1F5946: Generator (proces.c:4048)

This code is cut down from a larger test (#505). At this point it seems if I comment anything out, the error disappears:

#-

Off Statistics;

AutoDeclare Symbol n,m;
Symbol ep;
CFunction den,num;
Symbol coefftx,coeffty;

Local test4 = + den(ep)*den(ep^3*m3 + ep^2*m2 + ep*m1 + m0)*num(ep)*num(ep^3*n3 + ep^2*n2 + ep*n1 + n0);
Local test5 = + den(ep^3*m3 + ep^2*m2 + ep*m1 + m0)*num(ep^6*n6 + ep^5*n5 + ep^4*n4 + ep^3*n3 + ep^2*n2 + ep*n1 + n0);

FactArg num;
FactArg den;

SplitArg ((ep)) num;
Identify num(ep) = ep;
Transform num addargs(2,last);
FactArg num;

Print +s;
.end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions