Bug 58813 - SIGSEGV in show_locus at error.c:310
Summary: SIGSEGV in show_locus at error.c:310
Status: RESOLVED DUPLICATE of bug 59016
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.8.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2013-10-20 07:27 UTC by Vittorio Zecca
Modified: 2015-04-14 12:43 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.6.3
Known to fail: 4.7.3, 4.8.2, 4.9.0
Last reconfirmed: 2013-10-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vittorio Zecca 2013-10-20 07:27:13 UTC
! SIGSEGV in show_locus at error.c:310
! must be compiled as free form
! if seen as fixed format no SIGSEGV
! valgrind and sanitizer say invalid read at symbol.c:5001 "dummies = sym->formal;" 
! sym already freed at symbol.c:2519? In gfc_free_symbol "free (sym);"
! linked to bug 56674?
      MODULE m
      PUBLIC t
      CONTAINS
      SUBROUTINE s
       TYPE(t)
      END SUBROUTINE
      END MODULE
!f951: internal compiler error: Segmentation fault
!0x869b1f crash_signal
!        ../../gcc-4.8.2/gcc/toplev.c:332
!0x50b1eb show_locus
!        ../../gcc-4.8.2/gcc/fortran/error.c:310
!0x50ba80 show_loci
!        ../../gcc-4.8.2/gcc/fortran/error.c:434
!0x50ba80 error_print
!        ../../gcc-4.8.2/gcc/fortran/error.c:666
!0x50c568 gfc_error(char const*, ...)
!        ../../gcc-4.8.2/gcc/fortran/error.c:961
!0x5142e7 check_interface0
!        ../../gcc-4.8.2/gcc/fortran/interface.c:1477
!0x516bc4 check_sym_interfaces
!        ../../gcc-4.8.2/gcc/fortran/interface.c:1589
!0x57e493 do_traverse_symtree
!        ../../gcc-4.8.2/gcc/fortran/symbol.c:3575
!0x516cac gfc_check_interfaces(gfc_namespace*)
!        ../../gcc-4.8.2/gcc/fortran/interface.c:1699
!0x55d31e resolve_types
!        ../../gcc-4.8.2/gcc/fortran/resolve.c:14989
!0x55dba0 gfc_resolve
!        ../../gcc-4.8.2/gcc/fortran/resolve.c:15073
!0x552286 gfc_parse_file()
!        ../../gcc-4.8.2/gcc/fortran/parse.c:4614
!0x58e195 gfc_be_parse_file
!        ../../gcc-4.8.2/gcc/fortran/f95-lang.c:189
!Please submit a full bug report,
!with preprocessed source if appropriate.
!Please include the complete backtrace with any bug report.
Comment 1 kargls 2013-10-20 17:55:41 UTC
With trunk gfortran gives

troutmask:sgk[209] gfc4x -c b.f90
b.f90:5.16:

         type(t)
                1
Error: Derived type 't' at (1) is being used before it is defined
b.f90:7:

end module m
1
Error: Procedure 'block@6' in generic interface 't' at (1) is neither function nor subroutine
Comment 2 kargls 2013-10-20 18:40:41 UTC
(In reply to kargl from comment #1)
> With trunk gfortran gives
> 
> troutmask:sgk[209] gfc4x -c b.f90
> b.f90:5.16:
> 
>          type(t)
>                 1
> Error: Derived type 't' at (1) is being used before it is defined
> b.f90:7:
> 
> end module m
> 1
> Error: Procedure 'block@6' in generic interface 't' at (1) is neither
> function nor subroutine

I get a similar error message with 4.6.4, 4.7.4, and 4.8.2 20130916.
Comment 3 Tobias Burnus 2013-10-21 16:01:43 UTC
REOPEN.

I see this issue also with the trunk. With MALLOC_PERTURB_ set, it segfaults in

0x5f8e1c resolve_fl_procedure
        ../../gcc/fortran/resolve.c:10980


Without, it compiles, but shows:

Error: Procedure 'ySâ–’+' in generic interface 't' at (1) is neither function nor subroutine

where the procedure name is garbage.


(It works with GCC <= 4.6. I assume it is a side effect of the constructor patch.)
Comment 4 Steve Kargl 2013-10-21 16:18:05 UTC
On Mon, Oct 21, 2013 at 04:01:43PM +0000, burnus at gcc dot gnu.org wrote:
> 
> Error: Procedure 'yS???+' in generic interface 't' at (1) is neither
> function nor subroutine
> 
> where the procedure name is garbage.
> 

Like many error messages, this is a run-on error due to the
first one.  If one fixes the first error, the second goes
away.  The best fix would be to change gfc_option.max_errors 
from 25 to 1.
Comment 5 Vittorio Zecca 2013-10-21 17:38:02 UTC
I did not know about MALLOC_PERTURB_ I just put in my .bashrc profile
export MALLOC_PERTURB_=$(($RANDOM % 255 + 1))

gfortran fails in different places if the input file is .f or .f90

As .f I get bus error at resolve.c:11510 'gfc_notify_std
(GFC_STD_F2003, "Procedure "',
as .f90 I get segmentation fault at error.c:310 "error_string (f->filename);"
Comment 6 Vittorio Zecca 2013-10-22 06:40:22 UTC
I found that
export MALLOC_PERTURB_=256
produces a quiet NaN. I'll use this one in my .bashrc
It seems to me that the earlier symptom of malfunctioning
is in symbol.c:5001 " dummies = sym->formal;" where sym points the wrong way.
Comment 7 Steve Kargl 2013-10-22 13:07:53 UTC
On Tue, Oct 22, 2013 at 06:40:22AM +0000, zeccav at gmail dot com wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58813
> 
> --- Comment #6 from Vittorio Zecca <zeccav at gmail dot com> ---
> I found that
> export MALLOC_PERTURB_=256
> produces a quiet NaN. I'll use this one in my .bashrc
> It seems to me that the earlier symptom of malfunctioning
> is in symbol.c:5001 " dummies = sym->formal;" where sym points the wrong way.

What happens if you use -fmax-errors=1?
Comment 8 Vittorio Zecca 2013-10-22 17:14:07 UTC
If I use the option -fmax-errors=1 the ICE disappears, but using this
option as a default
would potentially increase the time needed to get an error free code.
A code containing many errors would require as many iterations of
error fixing and compilation.
I believe gfortran makes an excellent job at recovering from source
errors and issuing
as many as possible meaningful error messages.
This code is a special case where gfortran fails while recovering, in
my opinion this case
should be fixed to keep the current unlimited default for -fmax-errors.
Comment 9 kargls 2013-11-25 00:58:22 UTC
Remove myself from cc list.
Comment 10 Mikael Morin 2015-04-10 11:30:25 UTC
Author: mikael
Date: Fri Apr 10 11:29:53 2015
New Revision: 221972

URL: https://gcc.gnu.org/viewcvs?rev=221972&root=gcc&view=rev
Log:
	PR fortran/56674
	PR fortran/58813
	PR fortran/59016
	PR fortran/59024
fortran/
	* symbol.c (save_symbol_data, gfc_save_symbol_data): Rename the
	former to the latter and make it non-static.  Update callers.
	* gfortran.h (gfc_save_symbol_data): New prototype.
	* decl.c (gfc_match_decl_type_spec): Call 'gfc_save_symbol_data'
	before modifying symbols 'sym' and 'dt_sym'.
testsuite/
	* gfortran.dg/used_types_27.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/used_types_27.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/symbol.c
    trunk/gcc/testsuite/ChangeLog
Comment 11 Mikael Morin 2015-04-14 09:18:46 UTC
Author: mikael
Date: Tue Apr 14 09:18:15 2015
New Revision: 222078

URL: https://gcc.gnu.org/viewcvs?rev=222078&root=gcc&view=rev
Log:
	PR fortran/56674
	PR fortran/58813
	PR fortran/59016
	PR fortran/59024
fortran/
	* symbol.c (save_symbol_data, gfc_save_symbol_data): Rename the
	former to the latter and make it non-static.  Update callers.
	* gfortran.h (gfc_save_symbol_data): New prototype.
	* decl.c (gfc_match_decl_type_spec): Call 'gfc_save_symbol_data'
	before modifying symbols 'sym' and 'dt_sym'.
testsuite/
	* gfortran.dg/used_types_27.f90: New.


Added:
    branches/gcc-4_9-branch/gcc/testsuite/gfortran.dg/used_types_27.f90
Modified:
    branches/gcc-4_9-branch/gcc/fortran/ChangeLog
    branches/gcc-4_9-branch/gcc/fortran/decl.c
    branches/gcc-4_9-branch/gcc/fortran/gfortran.h
    branches/gcc-4_9-branch/gcc/fortran/symbol.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
Comment 12 Mikael Morin 2015-04-14 12:24:02 UTC
Author: mikael
Date: Tue Apr 14 12:23:30 2015
New Revision: 222086

URL: https://gcc.gnu.org/viewcvs?rev=222086&root=gcc&view=rev
Log:
	PR fortran/56674
	PR fortran/58813
	PR fortran/59016
	PR fortran/59024
fortran/
	* symbol.c (save_symbol_data, gfc_save_symbol_data): Rename the
	former to the latter and make it non-static.  Update callers.
	* gfortran.h (gfc_save_symbol_data): New prototype.
	* decl.c (gfc_match_decl_type_spec): Call 'gfc_save_symbol_data'
	before modifying symbols 'sym' and 'dt_sym'.
testsuite/
	* gfortran.dg/used_types_27.f90: New.


Added:
    branches/gcc-4_8-branch/gcc/testsuite/gfortran.dg/used_types_27.f90
Modified:
    branches/gcc-4_8-branch/gcc/fortran/ChangeLog
    branches/gcc-4_8-branch/gcc/fortran/decl.c
    branches/gcc-4_8-branch/gcc/fortran/gfortran.h
    branches/gcc-4_8-branch/gcc/fortran/symbol.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
Comment 13 Mikael Morin 2015-04-14 12:43:24 UTC
Dup.

*** This bug has been marked as a duplicate of bug 59016 ***