public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "irar at il dot ibm dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/39907]  New: Aligned access to unaligned address
Date: Sun, 26 Apr 2009 12:44:00 -0000	[thread overview]
Message-ID: <bug-39907-9531@http.gcc.gnu.org/bugzilla/> (raw)

The following code (a reduced gcc.target/x86_64/abi/test_struct_returning.c)
fails during execution with segmentation fault when compiled with -O1
-ftree-vectorize -fno-vect-cost-model asm-support.S  (in directory
gcc.target/x86_64/abi/):

#include <stdio.h>
#include "defines.h"
#include "macros.h"
#include "args.h"

struct S_600
{
 float f[4];
};

struct S_600 f_600 ()
{
  struct S_600 s;
  int i;

  for (i = 0; i < 4; i++)
    s.f[i] = 42;
  return s;
}

int
main (void)
{
  struct S_600 s;
  s = WRAP_RET(f_600) ();

  return 0;
}

The failure occurs in 
0x000000000040063b in f_600 ()
1: x/i $pc  0x40063b <f_600+7>: movaps %xmm0,0xffffffffffffffd8(%rsp)
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x000000000040063b in f_600 ()
1: x/i $pc  0x40063b <f_600+7>: movaps %xmm0,0xffffffffffffffd8(%rsp)

rsp            0x7fff408944c0   0x7fff408944c0
xmm0           {v4_float = {0x2a, 0x2a, 0x2a, 0x2a}, v2_double = {0xc00002114,
0xc00002114}, v16_int8 = {0x0, 0x0, 0x28,
    0x42, 0x0, 0x0, 0x28, 0x42, 0x0, 0x0, 0x28, 0x42, 0x0, 0x0, 0x28, 0x42},
v8_int16 = {0x0, 0x4228, 0x0, 0x4228, 0x0,
    0x4228, 0x0, 0x4228}, v4_int32 = {0x42280000, 0x42280000, 0x42280000,
0x42280000}, v2_int64 = {0x4228000042280000,
    0x4228000042280000}, uint128 = 0x42280000422800004228000042280000}

The alignment is forced by the vectorizer in function
vect_compute_data_ref_alignment() the same way as in pass
pass_ipa_increase_alignment. But if 's' is global and not local in f_600 (i.e.,
when the alignment is forced in pass_ipa_increase_alignment) there is no
segfault.

I also tried to remove WRAP_RET(), and put f_600 and main in different files
(in order to prevent their elimination). But this way there was no segfault
either.

Another check: if the vectorizer forces alignment but also uses peeling (with
the help of a hack), there is still a segfault:
0x000000000040065f in f_600 ()
1: x/i $pc  0x40065f <f_600+43>:        movaps 362(%rip),%xmm0        #
0x4007d0 <_IO_stdin_used+16>
(gdb)

1: x/i $pc  0x400666 <f_600+50>:        movaps %xmm0,(%rdx)
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0x0000000000400666 in f_600 ()
1: x/i $pc  0x400666 <f_600+50>:        movaps %xmm0,(%rdx)
(gdb) info all-registers

rdx            0x7fff2a759358   140733905736536
rip            0x400666 0x400666 <f_600+50>

If after forcing the alignment, the vectorizer escapes and doesn't do anything
else, there is no segfault.


-- 
           Summary: Aligned access to unaligned address
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: irar at il dot ibm dot com
 GCC build triplet: x86_64-suse-linux
  GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux


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


             reply	other threads:[~2009-04-26 12:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-26 12:44 irar at il dot ibm dot com [this message]
2009-04-26 16:54 ` [Bug tree-optimization/39907] " rguenth at gcc dot gnu dot org
2009-04-27  5:56 ` irar at il dot ibm dot com
2009-05-18 10:04 ` rguenth at gcc dot gnu dot org
2009-05-18 14:25 ` pinskia at gcc dot gnu dot org
2009-05-18 16:40 ` [Bug testsuite/39907] " hjl dot tools at gmail dot com
2009-05-18 16:53 ` hjl at gcc dot gnu dot org
2009-05-18 16:54 ` hjl at gcc dot gnu dot org
2009-05-18 16:57 ` hjl at gcc dot gnu dot org
2009-05-18 16:58 ` hjl dot tools at gmail dot com

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-39907-9531@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: link
Be 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).