This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/79699] New: small memory leak in MPFR


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79699

            Bug ID: 79699
           Summary: small memory leak in MPFR
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The gimple-ssa-sprintf pass seems to trigger a small memory leak in MPFR as the
test case below shows, presumably due to some caching by the library.  The leak
depends on the value on the floating argument and doesn't grow with the number
of sprintf calls or directives processed.

$ cat t.c && gcc -DX=123.4 -S -Wall -Wextra -Wpedantic t.c -wrapper
valgrind,--leak-check=full
int f (void)
{
  return __builtin_snprintf (0, 0, "%f", X);
}
==31067== Memcheck, a memory error detector
==31067== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==31067== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==31067== Command: /ssd/build/gcc-git-svn/gcc/cc1 -quiet -iprefix
/ssd/build/gcc-git-svn/gcc/../lib/gcc/x86_64-pc-linux-gnu/7.0.1/ -isystem
/ssd/build/gcc-git-svn/gcc/include -isystem
/ssd/build/gcc-git-svn/gcc/include-fixed -D X=123.4 t.c -quiet -dumpbase t.c
-mtune=generic -march=x86-64 -auxbase t -Wall -Wextra -Wpedantic -o t.s
==31067== 
==31067== 
==31067== HEAP SUMMARY:
==31067==     in use at exit: 1,808,389 bytes in 2,295 blocks
==31067==   total heap usage: 5,473 allocs, 3,178 frees, 3,892,322 bytes
allocated
==31067== 
==31067== 24 bytes in 1 blocks are possibly lost in loss record 13 of 624
==31067==    at 0x4C29C4F: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31067==    by 0x1CB1E22: __gmp_default_allocate (memory.c:54)
==31067==    by 0x1C45544: mpfr_init2 (init2.c:55)
==31067==    by 0x1C519E5: mpfr_cache (cache.c:61)
==31067==    by 0x1C22E0C: mpfr_log (log.c:129)
==31067==    by 0x1C4418B: mpfr_log2 (log2.c:119)
==31067==    by 0x1C2D916: mpfr_pow (pow.c:566)
==31067==    by 0x1C44AC9: mpfr_ui_pow (ui_pow.c:36)
==31067==    by 0x1C283FE: floor_log10 (vasprintf.c:825)
==31067==    by 0x1C29711: regular_fg (vasprintf.c:1366)
==31067==    by 0x1C2A28B: partition_number (vasprintf.c:1598)
==31067==    by 0x1C2A69F: sprnt_fp (vasprintf.c:1708)
==31067== 
==31067== 24 bytes in 1 blocks are possibly lost in loss record 14 of 624
==31067==    at 0x4C2BB9C: realloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==31067==    by 0x1CB1E7C: __gmp_default_reallocate (memory.c:102)
==31067==    by 0x1C30F78: mpfr_set_prec (set_prec.c:41)
==31067==    by 0x1C51A03: mpfr_cache (cache.c:66)
==31067==    by 0x1C22E59: mpfr_log (log.c:131)
==31067==    by 0x1C4418B: mpfr_log2 (log2.c:119)
==31067==    by 0x1C2D916: mpfr_pow (pow.c:566)
==31067==    by 0x1C44AC9: mpfr_ui_pow (ui_pow.c:36)
==31067==    by 0x1C283FE: floor_log10 (vasprintf.c:825)
==31067==    by 0x1C29711: regular_fg (vasprintf.c:1366)
==31067==    by 0x1C2A28B: partition_number (vasprintf.c:1598)
==31067==    by 0x1C2A69F: sprnt_fp (vasprintf.c:1708)
==31067== 
==31067== LEAK SUMMARY:
==31067==    definitely lost: 0 bytes in 0 blocks
==31067==    indirectly lost: 0 bytes in 0 blocks
==31067==      possibly lost: 48 bytes in 2 blocks
==31067==    still reachable: 1,808,341 bytes in 2,293 blocks
==31067==         suppressed: 0 bytes in 0 blocks
==31067== Reachable blocks (those to which a pointer was found) are not shown.
==31067== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==31067== 
==31067== For counts of detected and suppressed errors, rerun with: -v
==31067== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]