Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: maxlox on June 04, 2018, 07:19:12 pm

Title: Program received signal SIGSEGV: Segmentation fault - invalid memory reference
Post by: maxlox on June 04, 2018, 07:19:12 pm
Hi, I've write a simple program in fortran as follow:

Code
    program file1

    implicit none

    ! Prompt user for a filename and read it:
    CHARACTER*64 filename
    character*64 reading
    WRITE (*, '(A)') ' enter file to create: '
    READ (*, '(A)') filename
    ! Open the file for formatted sequential access as unit 7.
    ! Note that the specified access need not have been specified,
    ! since it is the default (as is "formatted").
    OPEN (7, FILE = filename, ACCESS = 'SEQUENTIAL', STATUS = 'NEW')
    write(7,*)'Nuovo file'

    open(10,file='pippo', access='sequential', status='old')
    read(10,*)reading
    close(7)
    close(10)

    write(*,*) reading

    print *, 'Hello World'

    end program file1

When I run it under Code::Blocks (ver. 17.12, the latest) ide o in command prompt I get an error message as in the image attached. Code::Blocks is installed in a OS windows 10 ( :o ) 64bit.
If I compile and run the same code with "my old computer" (a virtual machine over the same computer), with xp and visual studio intel fortran , all is good!

Can someone help me and show were I fall?

Thanks
Title: Re: Program received signal SIGSEGV: Segmentation fault - invalid memory reference
Post by: stahta01 on June 04, 2018, 07:27:48 pm
Please state the GCC and/or FORTRAN compiler version for both working and non-working versions.
Some GCC Compilers have know FORTRAN bugs!

Tim S.
Title: Re: Program received signal SIGSEGV: Segmentation fault - invalid memory reference
Post by: maxlox on June 05, 2018, 12:11:49 am
Please state the GCC and/or FORTRAN compiler version for both working and non-working versions.
Some GCC Compilers have know FORTRAN bugs!

Tim S.

Non working fortran compiler ver is the mingw32-gfortran.exe "GNU Fortran (tdm-1) 5.1.0".
The other, my old fortran compiler, working ver is the "Intel(R) Fortran Compiler 10.1.021 [IA-32]".

It's a compiler's bug?? Can I fix in someway?
Title: Re: Program received signal SIGSEGV: Segmentation fault - invalid memory reference
Post by: stahta01 on June 05, 2018, 06:51:42 am
Please state the GCC and/or FORTRAN compiler version for both working and non-working versions.
Some GCC Compilers have know FORTRAN bugs!

Tim S.

Non working fortran compiler ver is the mingw32-gfortran.exe "GNU Fortran (tdm-1) 5.1.0".
The other, my old fortran compiler, working ver is the "Intel(R) Fortran Compiler 10.1.021 [IA-32]".

It's a compiler's bug?? Can I fix in someway?

IIRC, "GNU Fortran (tdm-1) 5.1.0" is the bad FORTRAN compiler.
I would try an older or newer GCC FORTRAN compiler.

Tim S.
Title: Re: Program received signal SIGSEGV: Segmentation fault - invalid memory reference
Post by: maxlox on June 05, 2018, 07:16:05 pm
Quote

IIRC, "GNU Fortran (tdm-1) 5.1.0" is the bad FORTRAN compiler.
I would try an older or newer GCC FORTRAN compiler.

Tim S.

I'll try ...  :'( :'(

Thanks Tim S. "stahta01"
Title: Re: Program received signal SIGSEGV: Segmentation fault - invalid memory reference
Post by: BentL on June 11, 2018, 02:30:30 pm
You are doing file operations in Fortran and there is a bug in version 5.1.0 of file "libgfortran-3.dll" causing the error you describe. You need to update  file "libgfortran-3.dll" as described in this post (http://forums.codeblocks.org/index.php/topic,22354.msg152932.html#msg152932).
Title: Re: Program received signal SIGSEGV: Segmentation fault - invalid memory reference
Post by: maxlox on June 11, 2018, 09:01:58 pm
You are doing file operations in Fortran and there is a bug in version 5.1.0 of file "libgfortran-3.dll" causing the error you describe. You need to update  file "libgfortran-3.dll" as described in this post (http://forums.codeblocks.org/index.php/topic,22354.msg152932.html#msg152932).

Before I ask for help I've do it (installed the libgfortran-3 described in the post (http://forums.codeblocks.org/index.php/topic,22354.msg152932.html#msg152932)) ... but nothing  :-\
Title: Re: Program received signal SIGSEGV: Segmentation fault - invalid memory reference
Post by: karaul on June 12, 2018, 05:58:01 pm
I used mingw from here https://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version6/
With this replaced compiler, it works now.

(1) download small installer from the above link and install it in c:\mingw
(2) select the fortran package from the fresh installer and install
(3) change in the setting-complier for GNU fortran path to c:\mingw

The logic is clear, and I am sorry, if it the explanation is too short, I am writing this to repeat the procedure on another computer too.