flintlib / flint

FLINT (Fast Library for Number Theory)

Home Page:http://www.flintlib.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fmpz memory leak

fredrik-johansson opened this issue · comments

@albinahlback #1393 appears to be buggy; the fmpz cache is no longer being freed.

$ valgrind --leak-check=full --show-reachable=yes build/fmpz/test/main fmpz_mul
==1783797== Memcheck, a memory error detector
==1783797== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1783797== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==1783797== Command: build/fmpz/test/main fmpz_mul
==1783797== 
fmpz_mul....PASS
==1783797== 
==1783797== HEAP SUMMARY:
==1783797==     in use at exit: 69,632 bytes in 1 blocks
==1783797==   total heap usage: 44,250 allocs, 44,249 frees, 1,156,056 bytes allocated
==1783797== 
==1783797== 69,632 bytes in 1 blocks are definitely lost in loss record 1 of 1
==1783797==    at 0x4848899: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1783797==    by 0x49B512E: flint_malloc (memory_manager.c:109)
==1783797==    by 0x4A497DF: _fmpz_new_mpz (fmpz.c:92)
==1783797==    by 0x4A49D88: _fmpz_promote (fmpz.c:221)
==1783797==    by 0x4A49D88: _fmpz_promote (fmpz.c:217)
==1783797==    by 0x4A5A3C7: fmpz_randtest_unsigned (randtest.c:56)
==1783797==    by 0x4A5A495: fmpz_randtest (randtest.c:23)
==1783797==    by 0x1219BA: test_fmpz_mul (t-mul.c:36)
==1783797==    by 0x113CD9: main (main.c:365)
==1783797== 
==1783797== LEAK SUMMARY:
==1783797==    definitely lost: 69,632 bytes in 1 blocks
==1783797==    indirectly lost: 0 bytes in 0 blocks
==1783797==      possibly lost: 0 bytes in 0 blocks
==1783797==    still reachable: 0 bytes in 0 blocks
==1783797==         suppressed: 0 bytes in 0 blocks
==1783797== 
==1783797== For lists of detected and suppressed errors, rerun with: -s
==1783797== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Looks like atomic_add_fetch was erroneously changed to atomic_fetch_add.

I'll push a patch.