[Bug c++/86422] G++ ICE(segmentation fault) when compiling a huge static array of sufficiently complex structs

2018-07-09 Thread boris.staletic at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86422

--- Comment #8 from Boris Staletic  ---
> ulimit -s unlimited

After running that command and enabling swap, for a total of 16GB available
memory, until about 5 minute mark, cc1plus was consuming >4GB. After about five
minute mark, cc1plus started consuming memory rapidly, and in about a minute or
so, it consumed all 16GB. The end result is OOM killer stopping cc1plus.

[Bug c++/86422] G++ ICE(segmentation fault) when compiling a huge static array of sufficiently complex structs

2018-07-09 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86422

Richard Biener  changed:

   What|Removed |Added

 Status|NEW |WAITING

--- Comment #7 from Richard Biener  ---
Yeah, so there's into-SSA for example:

#63 0x01368cd6 in prepare_block_for_update (
bb=, insert_phi_p=true)
at /space/rguenther/src/svn/gcc-8-branch/gcc/tree-into-ssa.c:2677
2677prepare_block_for_update (son, insert_phi_p);
(gdb) l
2672
2673  /* Now visit all the blocks dominated by BB.  */
2674  for (son = first_dom_son (CDI_DOMINATORS, bb);
2675   son;
2676   son = next_dom_son (CDI_DOMINATORS, son))
2677prepare_block_for_update (son, insert_phi_p);

and there are many more in the tree.

So, can you check your stack ulimit and see if raising it solves the issue for
you (memory usage is still very high though).

[Bug c++/86422] G++ ICE(segmentation fault) when compiling a huge static array of sufficiently complex structs

2018-07-09 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86422

--- Comment #6 from Richard Biener  ---
So with a debug build I can see

(gdb) run
Starting program: /home/abuild/rguenther/gcc8-g/gcc/cc1plus -quiet
/tmp/CodePoint.ii

Program received signal SIGSEGV, Segmentation fault.
0x01576cf6 in verify_vssa (bb=, 
current_vdef=, visited=0x1389be00)
at /space/rguenther/src/svn/gcc-8-branch/gcc/tree-ssa.c:632
632   if (bitmap_bit_p (visited, bb->index))
(gdb) p bb
$1 = 

(ick btw, that are many basic blocks)

and the SEGFAULT is a stack overflow due to recursion in verify_vssa which
does

  /* Verify destination PHI uses and recurse.  */
  edge_iterator ei;
  edge e;
  FOR_EACH_EDGE (e, ei, bb->succs)
{
  gphi *phi = get_virtual_phi (e->dest);
  if (phi
  && PHI_ARG_DEF_FROM_EDGE (phi, e) != current_vdef)
{
  error ("PHI node with wrong VUSE on edge from BB %d",
 e->src->index);
  print_gimple_stmt (stderr, phi, 0, TDF_VOPS);
  fprintf (stderr, "expected ");
  print_generic_expr (stderr, current_vdef);
  fprintf (stderr, "\n");
  err = true;
}

  /* Recurse.  */
  err |= verify_vssa (e->dest, current_vdef, visited);

which is of course stupid.  I'll fix that.

Re-running with -fno-checking now to side-step the above issue (as said,
this is a --enable-checking build).

I do know we have some algorithms that recurse to dominator sons and
very likely the CFG structure will result in big recursion depth there
as well.

So maybe a workaround for you is to do ulimit -s unlimited?

[Bug c++/86422] G++ ICE(segmentation fault) when compiling a huge static array of sufficiently complex structs

2018-07-06 Thread rguenther at suse dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86422

--- Comment #5 from rguenther at suse dot de  ---
On July 6, 2018 6:10:23 PM GMT+02:00, "boris.staletic at gmail dot com"
 wrote:
>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86422
>
>--- Comment #4 from Boris Staletic 
>---
>I get the segmentations fault when running cc1plus directly. No matter
>if I
>pass -quiet or not.
>
>So what's the next step?
>
>Also, I have just noticed "Known to work: 8.1.1". Is that a mistake?

It works for me w/o segfault on the branch head.

[Bug c++/86422] G++ ICE(segmentation fault) when compiling a huge static array of sufficiently complex structs

2018-07-06 Thread boris.staletic at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86422

--- Comment #4 from Boris Staletic  ---
I get the segmentations fault when running cc1plus directly. No matter if I
pass -quiet or not.

So what's the next step?

Also, I have just noticed "Known to work: 8.1.1". Is that a mistake?

[Bug c++/86422] G++ ICE(segmentation fault) when compiling a huge static array of sufficiently complex structs

2018-07-06 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86422

Richard Biener  changed:

   What|Removed |Added

   Keywords||compile-time-hog,
   ||memory-hog
  Known to work||8.1.1
  Known to fail||8.1.0

--- Comment #3 from Richard Biener  ---
On the tip of the GCC 8 branch the segfault is gone (r262478).  I suspect the
error is memory use (it now peaks >20GB for me) and an unchecked allocation
or some 'int' size variable that overflows.

> /usr/bin/time /abuild/rguenther/obj/gcc/cc1plus -quiet CodePoint.ii
369.55user 7.52system 6:17.08elapsed 99%CPU (0avgtext+0avgdata
25329548maxresident)k
232inputs+604864outputs (0major+6777265minor)pagefaults 0swaps


Still needs tracking down thus.

[Bug c++/86422] G++ ICE(segmentation fault) when compiling a huge static array of sufficiently complex structs

2018-07-06 Thread boris.staletic at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86422

--- Comment #2 from Boris Staletic  ---
> so this time it's not parsing but code-generation that blows up things.

That makes sense, when I was playing with the file, it took between 5 to 10
seconds to report syntax errors.

Another thing that avoids the ICE is using a "RawCodePoint" with less
"std::string"s.

Anything else I should try?

[Bug c++/86422] G++ ICE(segmentation fault) when compiling a huge static array of sufficiently complex structs

2018-07-06 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86422

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-07-06
 Ever confirmed|0   |1

--- Comment #1 from Richard Biener  ---
For me with GCC 8 branch rN I have

> /usr/bin/time g++-8 CodePoint.ii -fsyntax-only
13.09user 0.86system 0:13.96elapsed 100%CPU (0avgtext+0avgdata
2270556maxresident)k
> /usr/bin/time g++-8 CodePoint.ii -S
g++-8: internal compiler error: Segmentation fault signal terminated program
cc1plus
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
135.05user 1.72system 2:16.78elapsed 99%CPU (0avgtext+0avgdata
4050164maxresident)k
0inputs+160outputs (0major+1514630minor)pagefaults 0swaps

so this time it's not parsing but code-generation that blows up things.

Shortening the testcase probably makes things small enough to not hit
GCCs various "limits" where it gives up "optimizing" due to too large
code and non-linear algorithms.

Confirmed.