public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] release ranger instance in pass_waccess (PR 101984)
@ 2021-08-19 18:44 Martin Sebor
  0 siblings, 0 replies; only message in thread
From: Martin Sebor @ 2021-08-19 18:44 UTC (permalink / raw)
  To: gcc-patches

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

The changes in last night's patch to the new access warning pass
(somewhat prematurely) included a call to enable_ranger() with no
matching call to disable_ranger().  The two calls must be paired
in order for the latter to release resources allocated by
the former, otherwise the resources leak and might cause GCC to
run out memory (as was observed in PR 101984).

Besides a native x86_64 build I have also tested the change with
the affected test and a powerpc-linux cross-compiler simply by
observing memory usage.  Committed as obvious in r12-3031.

Martin

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

PR middle-end/101984 - gimple-ssa-warn-access memory leak

gcc/ChangeLog:

	PR middle-end/101984
	* gimple-ssa-warn-access.cc (pass_waccess::execute): Also call
	disable_ranger.

diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
index f3efe564af0..4a2dd9ade77 100644
--- a/gcc/gimple-ssa-warn-access.cc
+++ b/gcc/gimple-ssa-warn-access.cc
@@ -3310,12 +3310,16 @@ pass_waccess::check (basic_block bb)
 unsigned
 pass_waccess::execute (function *fun)
 {
+  /* Create a new ranger instance and associate it with FUN.  */
   m_ranger = enable_ranger (fun);
 
   basic_block bb;
   FOR_EACH_BB_FN (bb, fun)
     check (bb);
 
+  /* Release the ranger instance and replace it with a global ranger.  */
+  disable_ranger (fun);
+
   return 0;
 }
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-19 18:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 18:44 [committed] release ranger instance in pass_waccess (PR 101984) Martin Sebor

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).