This is the mail archive of the gcc-patches@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]

[PATCH] PR lto/59441 Add initialization and release of bitmap obstack


Hi all,

Attached patch fixes PR lto/59441.
The reason of failure was that the default bitmap obstack was released just before the execution of early local passes. The error was found using valgrind. It reported that there were 153 invalid reads and 173 invalid writes into the field of the default bitmap obstack structure, and all of them were trying to access data that was free'd previously (at the same point of the program).

The solution is to add initialization and release of the bitmap obstack before and after the execution of early local passes. After applying this patch valgrind does not report any errors for the same testcase.

The patch was bootstrapped and regtested on x86_64-unknown-linux-gnu.

Ok for trunk?

Best regards,
Ilya Palachev
>From 9bf2878c0a74475283b5424f24e46b31feb13cf7 Mon Sep 17 00:00:00 2001
From: Ilya Palachev <i.palachev@samsung.com>
Date: Tue, 7 Oct 2014 16:09:25 +0400
Subject: [PATCH] Add initialization and release of bitmap obstack

gcc/

2014-10-07  Ilya Palachev  <i.palachev@samsung.com>

	* cgraphunit.c (process_new_functions): Add initialization and
	release of bitmap obstack before and after running of passes.

gcc/testsuite/

2014-10-07  Ilya Palachev  <i.palachev@samsung.com>

	* g++.dg/lto/pr59441_0.C: New test from bugzilla.
---
 gcc/cgraphunit.c                     |  6 +++++-
 gcc/testsuite/g++.dg/lto/pr59441_0.C | 26 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/lto/pr59441_0.C

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index d463505..ee42ad1 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -323,7 +323,11 @@ symbol_table::process_new_functions (void)
 	  push_cfun (DECL_STRUCT_FUNCTION (fndecl));
 	  if (state == IPA_SSA
 	      && !gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl)))
-	    g->get_passes ()->execute_early_local_passes ();
+	    {
+	      bitmap_obstack_initialize (NULL);
+	      g->get_passes ()->execute_early_local_passes ();
+	      bitmap_obstack_release (NULL);
+	    }
 	  else if (inline_summary_vec != NULL)
 	    compute_inline_parameters (node, true);
 	  free_dominance_info (CDI_POST_DOMINATORS);
diff --git a/gcc/testsuite/g++.dg/lto/pr59441_0.C b/gcc/testsuite/g++.dg/lto/pr59441_0.C
new file mode 100644
index 0000000..3c766e5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr59441_0.C
@@ -0,0 +1,26 @@
+// { dg-lto-do assemble }
+// { dg-lto-options { { -shared -fPIC -flto -O -fvtable-verify=std } } }
+
+template < typename T > struct A
+{
+  T foo ();
+};
+
+template < typename T > struct C: virtual public A < T >
+{
+  C & operator<< (C & (C &));
+};
+
+template < typename T >
+C < T > &endl (C < int > &c)
+{
+  c.foo ();
+    return c;
+}
+
+C < int > cout;
+void
+fn ()
+{
+  cout << endl;
+}
-- 
2.1.1


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