diff mbox

PR lto/59441 Add initialization and release of bitmap obstack

Message ID 5433E2B7.9020401@samsung.com
State New
Headers show

Commit Message

Ilya Palachev Oct. 7, 2014, 12:55 p.m. UTC
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

Comments

Richard Biener Oct. 7, 2014, 2:41 p.m. UTC | #1
On Tue, Oct 7, 2014 at 2:55 PM, Ilya Palachev <i.palachev@samsung.com> wrote:
> 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?

Ok.

Thanks,
Richard.

> Best regards,
> Ilya Palachev
diff mbox

Patch

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