[Bug 1720699]

Anlauf 1720699 at bugs.launchpad.net
Wed Dec 12 22:02:40 UTC 2018


(In reply to Dominique d'Humieres from comment #1)
> Confirmed from 4.8 up to trunk (9.0). An instrumented compiler gives
> 
> f951: Warning: No location in statement
> ../../work/gcc/fortran/trans.c:1768:39: runtime error: member access within
> null pointer of type 'struct gfc_linebuf'
> f951: internal compiler error: Segmentation fault: 11

The warning in comment#0 would be restored by the patch:

Index: gcc/fortran/trans.c
===================================================================
--- gcc/fortran/trans.c (revision 267065)
+++ gcc/fortran/trans.c (working copy)
@@ -1765,8 +1765,11 @@
 void
 gfc_set_backend_locus (locus * loc)
 {
-  gfc_current_backend_file = loc->lb->file;
-  input_location = loc->lb->location;
+  if (loc->lb)
+    {
+      gfc_current_backend_file = loc->lb->file;
+      input_location = loc->lb->location;
+    }
 }

However, this papers over the issue that the locus is not properly set.

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-5 in Ubuntu.
https://bugs.launchpad.net/bugs/1720699

Title:
  gfortran segfault on continuation at end of program followed by two or
  more newlines

Status in gcc:
  Confirmed
Status in gcc-5 package in Ubuntu:
  Incomplete
Status in gcc-6 package in Ubuntu:
  New
Status in gcc-7 package in Ubuntu:
  New

Bug description:
  If you end a FORTRAN program with the continuation character '&'
  followed by two newlines, gfortran SEGFAULTs when attempting to
  compile the program.

  This issue has a very minimal repro:

  file: test.f90
  ```
  end program &

  
  ```

  The two newlines at the end are significant. The problem does not
  repro with 1 or 0 newlines, though it does repro with more newlines.
  The problem also repros when any of the lines following the
  continuation contain a comment. The problem repros with both LF and
  CRLF line endings.

  I believe this program should compile without error.

  Putting a token anywhere after the continuation, even separated by 2
  or more newlines, results in the expected error messages.

  I'm running this on Windows Subsystem for Linux, though it's not
  likely that is causing this bug.

  The SEGFAULT error encountered:
  ```
  andre at ANDREW-DESKTOP:/mnt/c/Users/andre/Projects/scratch$ gfortran test.f90 -o hello
  f951: internal compiler error: Segmentation fault
  Please submit a full bug report,
  with preprocessed source if appropriate.
  See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
  ```

  gfortran --version
  ```
  andre at ANDREW-DESKTOP:/mnt/c/Users/andre/Projects/scratch$ gfortran --version
  GNU Fortran (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
  Copyright (C) 2015 Free Software Foundation, Inc.
  ```

  lsb_release -rd
  ```
  andre at ANDREW-DESKTOP:/mnt/c/Users/andre/Projects/scratch$ lsb_release -rd
  Description:    Ubuntu 16.04.3 LTS
  Release:        16.04
  ```

  apt-cache policy gfortran
  ```
  andre at ANDREW-DESKTOP:/mnt/c/Users/andre/Projects/scratch$ apt-cache policy gfortran
  gfortran:
    Installed: 4:5.3.1-1ubuntu1
    Candidate: 4:5.3.1-1ubuntu1
    Version table:
   *** 4:5.3.1-1ubuntu1 500
          500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
          100 /var/lib/dpkg/status
  ```

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/1720699/+subscriptions



More information about the foundations-bugs mailing list