public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-50499-4@http.gcc.gnu.org/bugzilla/> (raw) 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.
next reply other threads:[~2011-09-23 21:58 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-09-23 22:08 vries at gcc dot gnu.org [this message] 2011-09-23 22:11 ` [Bug target/50499] " vries at gcc dot gnu.org 2011-09-23 22:14 ` vries at gcc dot gnu.org 2012-02-02 15:07 ` bergner at gcc dot gnu.org 2012-02-02 15:09 ` bergner at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-50499-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).