Patchwork Fix extremely large LPBX arrays (PR gcov-profile/55650)

login
register
mail settings
Submitter Jakub Jelinek
Date Dec. 12, 2012, 7:41 p.m.
Message ID <20121212194106.GC2315@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/205633/
State New
Headers show

Comments

Jakub Jelinek - Dec. 12, 2012, 7:41 p.m.
Hi!

On the attached testcase prg_ctr_mask is non-zero, presumably set
while there still were some functions in the TU, but later on none of them
are being emitted.  This leads to n_functions in coverage_obj_finish being
0, and the array thus containing 0x100000000 elements.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2012-12-12  Jakub Jelinek  <jakub@redhat.com>

	PR gcov-profile/55650
	* coverage.c (coverage_obj_init): Return false if no functions
	are being emitted.

	* g++.dg/other/pr55650.C: New test.
	* g++.dg/other/pr55650.cc: New file.


	Jakub
Richard Guenther - Dec. 13, 2012, 10:06 a.m.
On Wed, Dec 12, 2012 at 8:41 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> On the attached testcase prg_ctr_mask is non-zero, presumably set
> while there still were some functions in the TU, but later on none of them
> are being emitted.  This leads to n_functions in coverage_obj_finish being
> 0, and the array thus containing 0x100000000 elements.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

Ok.

Thanks,
Richard.

> 2012-12-12  Jakub Jelinek  <jakub@redhat.com>
>
>         PR gcov-profile/55650
>         * coverage.c (coverage_obj_init): Return false if no functions
>         are being emitted.
>
>         * g++.dg/other/pr55650.C: New test.
>         * g++.dg/other/pr55650.cc: New file.
>
> --- gcc/coverage.c.jj   2012-11-19 14:41:24.000000000 +0100
> +++ gcc/coverage.c      2012-12-12 08:54:35.005180211 +0100
> @@ -999,6 +999,9 @@ coverage_obj_init (void)
>        /* The function is not being emitted, remove from list.  */
>        *fn_prev = fn->next;
>
> +  if (functions_head == NULL)
> +    return false;
> +
>    for (ix = 0; ix != GCOV_COUNTERS; ix++)
>      if ((1u << ix) & prg_ctr_mask)
>        n_counters++;
> --- gcc/testsuite/g++.dg/other/pr55650.C.jj     2012-12-12 09:03:53.342876593 +0100
> +++ gcc/testsuite/g++.dg/other/pr55650.C        2012-12-12 09:03:11.000000000 +0100
> @@ -0,0 +1,21 @@
> +// PR gcov-profile/55650
> +// { dg-do link }
> +// { dg-options "-O2 -fprofile-generate" }
> +// { dg-additional-sources "pr55650.cc" }
> +
> +struct A
> +{
> +  virtual void foo ();
> +};
> +
> +struct B : public A
> +{
> +  B ();
> +  void foo () {}
> +};
> +
> +inline A *
> +bar ()
> +{
> +  return new B;
> +}
> --- gcc/testsuite/g++.dg/other/pr55650.cc.jj    2012-12-12 09:03:56.329858741 +0100
> +++ gcc/testsuite/g++.dg/other/pr55650.cc       2012-12-12 09:03:48.982900718 +0100
> @@ -0,0 +1,4 @@
> +int
> +main ()
> +{
> +}
>
>         Jakub

Patch

--- gcc/coverage.c.jj	2012-11-19 14:41:24.000000000 +0100
+++ gcc/coverage.c	2012-12-12 08:54:35.005180211 +0100
@@ -999,6 +999,9 @@  coverage_obj_init (void)
       /* The function is not being emitted, remove from list.  */
       *fn_prev = fn->next;
 
+  if (functions_head == NULL)
+    return false;
+
   for (ix = 0; ix != GCOV_COUNTERS; ix++)
     if ((1u << ix) & prg_ctr_mask)
       n_counters++;
--- gcc/testsuite/g++.dg/other/pr55650.C.jj	2012-12-12 09:03:53.342876593 +0100
+++ gcc/testsuite/g++.dg/other/pr55650.C	2012-12-12 09:03:11.000000000 +0100
@@ -0,0 +1,21 @@ 
+// PR gcov-profile/55650
+// { dg-do link }
+// { dg-options "-O2 -fprofile-generate" }
+// { dg-additional-sources "pr55650.cc" }
+
+struct A
+{
+  virtual void foo ();
+};
+
+struct B : public A
+{
+  B ();
+  void foo () {}
+};
+
+inline A *
+bar ()
+{
+  return new B;
+}
--- gcc/testsuite/g++.dg/other/pr55650.cc.jj	2012-12-12 09:03:56.329858741 +0100
+++ gcc/testsuite/g++.dg/other/pr55650.cc	2012-12-12 09:03:48.982900718 +0100
@@ -0,0 +1,4 @@ 
+int
+main ()
+{
+}