public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/43220]  New: Paritially optimized __builtin_save_stack/__builtin_restore_stack causes segmentation fault
@ 2010-03-01 14:07 bmei at broadcom dot com
  2010-03-01 15:00 ` [Bug tree-optimization/43220] [4.3/4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: bmei at broadcom dot com @ 2010-03-01 14:07 UTC (permalink / raw)
  To: gcc-bugs

I encountered a segmentation fault when executing an unrolled version of
20040811-1.c (tested with -O2)

void *volatile p;

int
main (void)
{
  int n = 0;
 lab:;
  {
  int x[n % 1000 + 1];
  x[0] = 1;
  x[n % 1000] = 2;
  p = x;
  n++;
  }


  {
  int x[n % 1000 + 1];
  x[0] = 1;
  x[n % 1000] = 2;
  p = x;
  n++;
  }

  if (n < 1000000)
    goto lab;

  return 0;
}

The problem is that the first pair of
__builtin_stack_save/__builtin_satck_restore of the unrolled loop is optimized
out in optimize_stack_restore (tree-ssa-ccp.c) of fab pass. Consequently, the
dynamic memory allocated grows bigger and bigger and causes segfault. The
following is from tst.c.139t.optimized


lab:
  saved_stack.1_3 = 0B;
  D.2723_4 = n_1 % 1000;
  D.2724_5 = D.2723_4 + 1;
  D.2728_15 = (long unsigned int) D.2724_5;
  D.2730_16 = D.2728_15 * 4;
  D.2732_17 = __builtin_alloca (D.2730_16);
  x.0_18 = (int[0:D.2727] *) D.2732_17;
  (*x.0_18)[0] = 1;
  (*x.0_18)[D.2723_4] = 2;
  p ={v} x.0_18;
  D.2770_66 = (unsigned int) n_1;
  D.2771_65 = D.2770_66 + 1;
  n_64 = (int) D.2771_65;
  GIMPLE_NOP
  saved_stack.3_21 = __builtin_stack_save ();
  D.2723_22 = n_64 % 1000;
  D.2734_23 = D.2723_22 + 1;
  D.2738_33 = (long unsigned int) D.2734_23;
  D.2740_34 = D.2738_33 * 4;
  D.2742_35 = __builtin_alloca (D.2740_34);
  x.2_36 = (int[0:D.2737] *) D.2742_35;
  (*x.2_36)[0] = 1;
  (*x.2_36)[D.2723_22] = 2;
  p ={v} x.2_36;
  D.2773_62 = D.2770_66 + 2;
  n_61 = (int) D.2773_62;
  __builtin_stack_restore (saved_stack.3_21);
  if (n_61 != 1000000)
    goto <bb 3> (lab);
  else
    goto <bb 4>;


-- 
           Summary: Paritially optimized
                    __builtin_save_stack/__builtin_restore_stack causes
                    segmentation fault
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bmei at broadcom dot com
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43220


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-04-20 14:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-01 14:07 [Bug tree-optimization/43220] New: Paritially optimized __builtin_save_stack/__builtin_restore_stack causes segmentation fault bmei at broadcom dot com
2010-03-01 15:00 ` [Bug tree-optimization/43220] [4.3/4.4/4.5 Regression] " rguenth at gcc dot gnu dot org
2010-03-01 15:16 ` rguenth at gcc dot gnu dot org
2010-03-01 16:57 ` [Bug tree-optimization/43220] [4.3/4.4 " rguenth at gcc dot gnu dot org
2010-03-01 16:57 ` rguenth at gcc dot gnu dot org
2010-03-02  7:44 ` jakub at gcc dot gnu dot org
2010-03-02  7:47 ` [Bug tree-optimization/43220] [4.3 " jakub at gcc dot gnu dot org
2010-04-20 14:25 ` rguenth at gcc dot gnu dot org
2010-04-20 14:25 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).