public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] free MPFR caches in gimple-ssa-sprintf.c (PR 79699)
@ 2017-03-01 23:32 Martin Sebor
  2017-03-02  1:01 ` Joseph Myers
  0 siblings, 1 reply; 7+ messages in thread
From: Martin Sebor @ 2017-03-01 23:32 UTC (permalink / raw)
  To: Gcc Patch List, Joseph Myers

[-- Attachment #1: Type: text/plain, Size: 875 bytes --]

The uses of MPFR in gimple-ssa-sprintf.c apparently cause
the library to allocates some internal caches that it then leaks
on program exit, causing Valgrind memory leak errors.  The MPFR
manual "strongly advises to [call mpfr_free_cache] before
terminating a thread, or before exiting when using tools like
'valgrind' (to avoid memory leaks being reported)) so the attached
patch does just that.

It' seems like an obvious fix that could presumably be committed
without a review or approval but I'd like to give others a chance
to comment on the placement of the call and whether it should be
guarded by ENABLE_VALGRIND_ANNOTATIONS.

Joseph, since you commented on the bug, do you have a suggestion
for a different site for it or a guard?  The only other call to
the function is in the Fortran FE and it's neither guarded nor
does it appear to ever be called.

Thanks
Martin

[-- Attachment #2: gcc-79699.diff --]
[-- Type: text/x-patch, Size: 592 bytes --]

PR tree-optimization/79699 - small memory leak in MPFR

gcc/ChangeLog:

	PR tree-optimization/79699
	* gimple-ssa-sprintf.c (pass_sprintf_length::execute): Free MPFR
	caches to avoid a memory leak on program exit.

diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 7688439..0c00fa0 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -3612,6 +3612,8 @@ pass_sprintf_length::execute (function *fun)
   /* Clean up object size info.  */
   fini_object_sizes ();
 
+  /* Clean up MPFR caches (see bug 79699).  */
+  mpfr_free_cache ();
   return 0;
 }
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-03-03 11:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-01 23:32 [PATCH] free MPFR caches in gimple-ssa-sprintf.c (PR 79699) Martin Sebor
2017-03-02  1:01 ` Joseph Myers
2017-03-02  8:08   ` Richard Biener
2017-03-02 21:34     ` Martin Sebor
2017-03-02 21:40       ` Andrew Pinski
2017-03-02 21:56         ` Martin Sebor
2017-03-03 11:02       ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).