News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Program received signal SIGSEGV: Segmentation fault - invalid memory reference

Started by maxlox, June 04, 2018, 07:19:12 PM

Previous topic - Next topic

maxlox

Hi, I've write a simple program in fortran as follow:

    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

stahta01

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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

maxlox

Quote from: 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.

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?

stahta01

Quote from: maxlox on June 05, 2018, 12:11:49 AM
Quote from: 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.

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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

maxlox

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"

BentL

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.

maxlox

Quote from: 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.

Before I ask for help I've do it (installed the libgfortran-3 described in the post) ... but nothing  :-\

karaul

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.