From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13751 invoked by alias); 23 Sep 2011 21:58:05 -0000 Received: (qmail 13742 invoked by uid 22791); 23 Sep 2011 21:58:04 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Sep 2011 21:57:49 +0000 From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [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 Date: Fri, 23 Sep 2011 22:08:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg01713.txt.bz2 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.