Bug 30779 - [4.1, 4.2 only] incomplete file triggers ICE
Summary: [4.1, 4.2 only] incomplete file triggers ICE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Jerry DeLisle
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2007-02-12 19:13 UTC by Joost VandeVondele
Modified: 2007-02-16 23:52 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-02-14 00:43:31


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2007-02-12 19:13:42 UTC
trying to find a testcase for what is currently an issue in PR29975 I ran into this:

vondele@pcihopt1:/scratch/vondele/clean/cp2k/obj/Linux-x86-64-gfortran/sdbg> gfortran t.f90
t.f90:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
vondele@pcihopt1:/scratch/vondele/clean/cp2k/obj/Linux-x86-64-gfortran/sdbg> cat t.f90
MODULE M1
 INTEGER :: I
END MODULE M1

USE M1,                    ONLY: I,&
Comment 1 Thomas Koenig 2007-02-12 19:29:55 UTC
Confirmed.

Backtrace:

(gdb) r t.f90
Starting program: /home/ig25/libexec/gcc/i686-pc-linux-gnu/4.3.0/f951 t.f90
Failed to read a valid object file image from memory.
t.f90:1:

cat t.f90
1
Error: Unclassifiable statement at (1)

Program received signal SIGSEGV, Segmentation fault.
0x0809a6d7 in gfc_next_char_literal (in_string=0)
    at /home/ig25/gcc/trunk/gcc/fortran/scanner.c:711
711           if (gfc_current_locus.lb->linenum == continue_line + 1)
Comment 2 Joost VandeVondele 2007-02-12 20:12:03 UTC
(In reply to comment #1)
> Confirmed.
> 
> Backtrace:
> 
> (gdb) r t.f90
> Starting program: /home/ig25/libexec/gcc/i686-pc-linux-gnu/4.3.0/f951 t.f90
> Failed to read a valid object file image from memory.
> t.f90:1:
> 
> cat t.f90
> 1
> Error: Unclassifiable statement at (1)
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x0809a6d7 in gfc_next_char_literal (in_string=0)
>     at /home/ig25/gcc/trunk/gcc/fortran/scanner.c:711
> 711           if (gfc_current_locus.lb->linenum == continue_line + 1)
> 
looks like you discovered an independent bug, in my case the 'cat t.f90' wasn't part of the program (but it is the command line that wraps) and in my case there is no error message.
Comment 3 Paul Thomas 2007-02-13 21:00:18 UTC
Jerry is our expert on this side of things.  Although he has said that he is in temporary hiding from gfortran, I have CC'd him:)

Paul
Comment 4 Jerry DeLisle 2007-02-14 00:43:31 UTC
I'll give it a go.  Just be patient please. :)
Comment 5 Jerry DeLisle 2007-02-14 20:31:39 UTC
The patch is straight forward.  Need to check for end of file after advance_line in scanner.c in a couple of places.  I just need to finish testing and package the  submit.  Maybe tonight.
Comment 6 Paul Thomas 2007-02-14 20:54:02 UTC
Subject: Re:  incomplete file triggers ICE

jvdelisle at gcc dot gnu dot org wrote:
> ------- Comment #5 from jvdelisle at gcc dot gnu dot org  2007-02-14 20:31 -------
> The patch is straight forward.  Need to check for end of file after
> advance_line in scanner.c in a couple of places.  I just need to finish testing
> and package the  submit.  Maybe tonight.
>
>
>   
Good-oh! I knew that you would go straight for it.

Paul

Comment 7 patchapp@dberlin.org 2007-02-15 06:25:18 UTC
Subject: Bug number PR30779

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-02/msg01321.html
Comment 8 Jerry DeLisle 2007-02-15 06:48:19 UTC
Subject: Bug 30779

Author: jvdelisle
Date: Thu Feb 15 06:48:09 2007
New Revision: 121982

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121982
Log:
2007-02-14  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/30779
	* scanner.c (gfc_next_char_literal): Add check for end of file after
	call to advance_line.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/scanner.c

Comment 9 Jerry DeLisle 2007-02-15 06:51:52 UTC
Subject: Bug 30779

Author: jvdelisle
Date: Thu Feb 15 06:51:42 2007
New Revision: 121983

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121983
Log:
2007-02-15  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/30779
	* gfortran.dg/error_recovery_3.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/error_recovery_3.f90
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 10 Jerry DeLisle 2007-02-15 07:04:01 UTC
Fixed on 4.3.
Comment 11 Jerry DeLisle 2007-02-16 23:42:21 UTC
Subject: Bug 30779

Author: jvdelisle
Date: Fri Feb 16 23:42:11 2007
New Revision: 122059

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122059
Log:
2007-02-16  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/30779
	* scanner.c (gfc_next_char_literal): Add check for end of file after
	call to advance_line.

2007-02-16  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/30779
	* gfortran.dg/error_recovery_3.f90: New test.


Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/error_recovery_3.f90
Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/scanner.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 12 Jerry DeLisle 2007-02-16 23:52:22 UTC
No need to go to 4.1.  This is an ICE on invalid.