diff mbox series

[committed] release ranger instance in pass_waccess (PR 101984)

Message ID bee96893-70b3-d91c-2ab3-555b2a8f3c7d@gmail.com
State New
Headers show
Series [committed] release ranger instance in pass_waccess (PR 101984) | expand

Commit Message

Martin Sebor Aug. 19, 2021, 6:44 p.m. UTC
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
diff mbox series

Patch

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;
 }