Currently an use of get() method of dump_context singleton in optinfo
framework causes a new class to be instantiated, which calls the singleton
dtor when the class is destroyed, freeing memory that is referenced after
free() is called, generating an ICE error.

This commit fixes the issue by using singleton's static member get()
directly to get the singleton's active instance, which doesn't instantiate
a new class, so no dtor is called.

gcc/Changelog:
2020-04-06  Gustavo Romero  <grom...@linux.ibm.com>

        * dumpfile.c:
        (selftest::temp_dump_context::temp_dump_context): Fix ctor.
---
 gcc/dumpfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
index 468ffab..d0d8aa7 100644
--- a/gcc/dumpfile.c
+++ b/gcc/dumpfile.c
@@ -2076,7 +2076,7 @@ temp_dump_context::temp_dump_context (bool 
forcibly_enable_optinfo,
                                      bool forcibly_enable_dumping,
                                      dump_flags_t test_pp_flags)
 : m_context (),
-  m_saved (&dump_context ().get ())
+  m_saved(&dump_context::get())
 {
   dump_context::s_current = &m_context;
   if (forcibly_enable_optinfo)
-- 
2.7.4

Reply via email to