Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28996 Discussions

Small program segfaults on READ from internal file

Øyvind_J_
Beginner
764 Views

The following program gives a segfault with Intel 15.0.2 on Linux:

PROGRAM read_empty_substing
  CHARACTER(LEN=20) :: c_in = "hello"
  CHARACTER(LEN=20) :: c_out
  INTEGER :: i_iostat

  ! These statements give a segfault with Intel 15.0.2
  READ(c_in(2:1), '(A)')  c_out 
  READ(c_in(2:1), '(A)', IOSTAT=i_iostat)  c_out 

  ! The following statements give end-of-file as expected:
  !READ(c_in(2:1), *) c_out
  !READ(c_in(2:1), *, IOSTAT=i_iostat) c_out

  print *, TRIM(c_out)
END PROGRAM

As you can see, we try to read from an empty substring of c_in, and I do expect an error condition, i.e. i_iostat/=0. Instead I get a segfault. The read statements with format string segfaults, while the list directed read gives end-of-file. Am I supposed to check the length of the internal file before I read from it, or could this be a compiler bug?

Øyvind

------------------------

(gdb) run
Starting program: /fs/auto/home/oyvindj/tmp/read_segfault/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Catchpoint -2 (signal SIGSEGV), 0x00000000004804c6 in __intel_ssse3_rep_memcpy ()
(gdb) bt
#0  0x00000000004804c6 in __intel_ssse3_rep_memcpy ()
#1  0x0000000000409546 in for_read_int_fmt_xmit ()
#2  0x000000000040783f in for_read_int_fmt ()
#3  0x0000000000402e01 in read_empty_substing () at read.f90:7
#4  0x0000000000402d5e in main ()

 

0 Kudos
1 Solution
Steven_L_Intel1
Employee
764 Views

This is our bug - I'll let the developers know. Thanks. Issue ID is DPD200369590.

View solution in original post

0 Kudos
3 Replies
Steven_L_Intel1
Employee
765 Views

This is our bug - I'll let the developers know. Thanks. Issue ID is DPD200369590.

0 Kudos
Øyvind_J_
Beginner
764 Views

Thanks!

0 Kudos
Steven_L_Intel1
Employee
764 Views

I expect this bug to be fixed in the 16.0 release.

0 Kudos
Reply