public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ondrej.certik at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/62142] internal compiler error: Segmentation fault (X = X - L*floor(X/L))
Date: Thu, 14 Aug 2014 18:55:00 -0000	[thread overview]
Message-ID: <bug-62142-4-1bg4qlmjjY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-62142-4@http.gcc.gnu.org/bugzilla/>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 6493 bytes --]

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62142

--- Comment #1 from Ondřej Čertík <ondrej.certik at gmail dot com> ---
One can actually isolate it even further (the same stacktrace):

program test_segfault
implicit none
real, allocatable :: X(:)
X = floor(X)
end program
>From gcc-bugs-return-458499-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Aug 14 19:03:23 2014
Return-Path: <gcc-bugs-return-458499-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 16292 invoked by alias); 14 Aug 2014 19:03:22 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 16233 invoked by uid 48); 14 Aug 2014 19:03:15 -0000
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/62142] internal compiler error: Segmentation fault (X = X - L*floor(X/L))
Date: Thu, 14 Aug 2014 19:03:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.9.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: kargl 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-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-62142-4-JwKog83Cvx@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-62142-4@http.gcc.gnu.org/bugzilla/>
References: <bug-62142-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-08/txt/msg00996.txt.bz2
Content-length: 2049

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62142

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to Ondřej Čertík from comment #0)
> Created attachment 33327 [details]
> Source file to reproduce the segfault
> 
> $ cat test_segfault.f90 
> program test_segfault
> implicit none
> integer, parameter :: dp=kind(0.d0)
> real(dp) :: L
> real(dp), allocatable :: X(:)
> X = X - L*floor(X/L)
> end program
> 

(snip)

> When I execute "gfortran -v -save-temps  test_segfault.f90", it doesn't
> produce preprocessed sources, I assume the segfault happens in the parser. I
> have isolated the segfault, it happens in a large codebase and prevents its
> compilation (the array is allocated in our code, the above is the simplest
> code to reproduce the problem).
> 
> This is my first bug report, please let me know if you need further
> information.

For such a short program, we don't necessarily need -save-temps.
Note, your reduce test case is nonconforming code because it 
uses L and X in a RHS expression without being defined.  With the
small change

program test_segfault
implicit none
integer, parameter :: dp=kind(0.d0)
real(dp) :: L
real(dp), allocatable :: X(:)
L = 42
X = [1, 2]
X = X - L*floor(X/L)
end program

the code is now conforming and it still exhibits the bug.

I suspect that the bug is due to a combination of -frealloc-lhs
and that floor is generated as inline code.  With -frealloc-lhs,
I get the same ICE that you find.  With -fno-realloc-lhs, I get
a compiled executable but it segfaults at runtime because x = [1,2]
obviously won't work.  If I add an allocate(x(2)) prior to 
x = [1,2], then -fno-realloc-lhs produced executable runs as
expected.  So, as a workaround explicitly allocate memory and
use -fno-realloc-lhs.
>From gcc-bugs-return-458500-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Aug 14 19:07:29 2014
Return-Path: <gcc-bugs-return-458500-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 19719 invoked by alias); 14 Aug 2014 19:07:28 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 19669 invoked by uid 48); 14 Aug 2014 19:07:23 -0000
From: "hubicka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/62091] [5 Regression] ice in before_dom_children
Date: Thu, 14 Aug 2014 19:07:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: hubicka at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: attachments.created
Message-ID: <bug-62091-4-VClAWWrp7N@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-62091-4@http.gcc.gnu.org/bugzilla/>
References: <bug-62091-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-08/txt/msg00997.txt.bz2
Content-length: 538

https://gcc.gnu.org/bugzilla/show_bug.cgi?idb091

--- Comment #5 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Created attachment 33329
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id3329&actioníit
Path I am testing

The disagreemeng actually turned out to be subtle bug in tree-ssa-alias.c where
function_entry_reached was incorrectly incorrectly initialized to false during
recursive walk :(

I am testing the following patch that makes us to not devirtualize in this
case. We still ought to solve the visibility issues


  reply	other threads:[~2014-08-14 18:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-14 17:56 [Bug fortran/62142] New: " ondrej.certik at gmail dot com
2014-08-14 18:55 ` ondrej.certik at gmail dot com [this message]
2014-08-14 19:17 ` [Bug fortran/62142] " ondrej.certik at gmail dot com
2014-08-15  8:42 ` [Bug fortran/62142] [4.9/5 Regression] " dominiq at lps dot ens.fr
2014-08-15  8:52 ` dominiq at lps dot ens.fr
2014-08-15 10:02 ` rguenth at gcc dot gnu.org
2014-08-15 12:39 ` jakub at gcc dot gnu.org
2014-08-15 20:34 ` tkoenig at gcc dot gnu.org
2014-08-15 21:20 ` tkoenig at gcc dot gnu.org
2014-08-16  9:45 ` tkoenig at gcc dot gnu.org
2014-08-16  9:46 ` tkoenig 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-62142-4-1bg4qlmjjY@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).