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

[Bug target/50499] New: segmentation fault in gcc.dg/compat/struct-by-value-1 c_compat_x_tst.o-c_compat_y_tst.o with ppc -m64


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

             Bug #: 50499
           Summary: segmentation fault in gcc.dg/compat/struct-by-value-1
                    c_compat_x_tst.o-c_compat_y_tst.o with ppc -m64
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vries@gcc.gnu.org


The relevant C code from the testcase is this:
...
struct S50 {
  unsigned char i[50];
}

void init50 (struct S50 *p, int i) {
  int j;
  for (j = 0; j < 50; j++)
    p->i[j] = i + j;
}

void check50 (struct S50 x, int i) {
  int j;
  for (j = 0; j < 50; j++)
    if (x.i[j] != i + j)
      abort ();
}

struct S50 g1s50, g2s50, g3s50;

void checkg50 (void) {
  check50 (g1s50, 64);
  check50 (g2s50, 128);
  check50 (g3s50, 192);
}

void testit50 (void) {

  init50 (&g1s50, 64);
  init50 (&g2s50, 128);
  init50 (&g3s50, 192);
  checkg50 ();
  test50 (g1s50, g2s50, g3s50);
  test2_50 (g1s50, g3s50);
}
...

In checkg50, the code for the second call to check50 looks like this:
...
        addis 9,2,.LC152@toc@ha
        mr 0,9
        mr 11,0
        ld 0,.LC152@toc@l(11)
        mr 9,0
        ld 3,0(9)
        mr 11,0
        ld 4,8(11)
        mr 9,0
        ld 5,16(9)
        mr 11,0
        ld 6,24(11)
        mr 9,0
        ld 7,32(9)
        mr 11,0
        ld 8,40(11)
        mr 11,0
        ld 9,48(11)
        li 10,192
        bl check50
...

I ran into a segmentation fault while executing 'ld 9,48(11)', the last load.

The LC152 data referenced is declared here:
...
.LC150:
        .tc g1s50[TC],g1s50
.LC151:
        .tc g2s50[TC],g2s50
.LC152:
        .tc g3s50[TC],g3s50
        .section        ".text"
...

and defined here:
...
        .comm   g1s50,50,1
        .comm   g2s50,50,1
        .comm   g3s50,50,1
...

So g2s50 is only 50 chars big, but we try to read 52 chars from it. We happen
not to have access to the 2 extra chars, and this causes the segmentation
violation.


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