- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have just rebuilt a project using the latest version of the IFORT compiler and the resulting program crashed with an Access Violation Exception. The same code did not flag any exceptions and appeared to work as intended when compiled with 2021.3.0 or any earlier versions. The culprit seems to be either backspace or the ifport function GETPOSI8.
I've created a reproducer which demonstrates this in attached zip file containing source code, data and solution files.
program FilePosBug
implicit none
! Local variables
character(132) :: Filename = 'Main_File.txt'
character(132) :: buf
logical :: TOF,TOF1,TOF2
integer :: linecount
integer :: ier
integer :: io
! Function
logical :: utl_TopOfFile
! Initialise
io = 8
linecount = 0
! open a text file (must have over 107 lines)
Open(unit=io,file=FileName,status='old',iostat=ier)
if(ier.eq.0) then
! Scan file
do
read(io,'(a)',iostat=ier) buf
if(ier.eq.-1) exit
linecount = linecount + 1
backspace(io,iostat=ier)
TOF1 = utl_TopOfFile(io)
backspace(io,iostat=ier)
TOF2 = utl_TopOfFile(io)
TOF = TOF1.and.TOF2
! Reread
read(io,'(a)',iostat=ier) buf
if(.not.TOF) then
read(io,'(a)',iostat=ier) buf
endif
write(*,'(a,i5,2x,a)') 'Line count ', linecount, buf
enddo
close(unit=io)
else
write(*,'(a)') 'Error: Cannot open file '//trim(filename)
endif
end program
logical function utl_TopOfFile(iunit)
!**************************************************************
! Return true if file access pointer is at the top of the file
!**************************************************************
use ifport
implicit none
! Arguments
integer,intent(in) :: iunit
! Local Variables
integer(8) :: ipos
! Initialise
utl_TopOfFile = .false.
ipos = GetPosI8(iunit)
if(ipos.eq.0) then
utl_TopOfFile = .true.
endif
return
end function
The idea of the code is to identify if the line read is the first line in the file. It is not that elegant but has done the job for a number of years until now. In the reproducer example the same function is called repeatedly (once for each line in the text file) and program eventually crashes after107 calls.
The text file can contain any data but consist of at least 107 lines.
I have only looked at x64 configuration and confirm that this access violation is occurring when compiled with IFORT 2021.4.0.
Hopefully someone at Intel can have a look at this.
Thanks,
Steve
- Tags:
- GETPOSI8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for such a nice reproducer! I printed ier after each backspace; it always returns 0. That's good. I also printed ipos after the call to GetPosI8(). The values of ipos are different between the 2021.4.0 compiler and 2021.3.0. Looks like a regression.
I filed a bug on your behalf, CMPLRLIBS-33593. I'll keep you posted on its progress to a fix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Barbara, I'll stick with 2021.3.0 for now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This issue is fixed in ifort version 2021.6.0. It was released recently as part of Intel oneAPI 2022.2.
Please give it a try!

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page