- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I have a DLL that has been running well for years. Following a small modification I now find that a file read loop crashes at end of file when I run the DLL in release mode, but it works perfectly well in debug mode.
I have stripped the problem down to this simple piece of code:
integer(8) area,perimeter
integer(4) idx
open(12,file='C:\Temp\temp.txt',status='old',iostat=ios,err=1000)
eof = .false.
read(12,'(F20.8,F20.8,I10)',iostat=ios)area,perimeter,idx
if(ios==-1)then
eof = .true.
else if(ios/=0)then
goto 1000
end if
do while(.not.eof)
read(12,'(F20.8,F20.8,I10)',iostat=ios)area,perimeter,idx
if(ios==-1)then
eof = .true.
else if(ios/=0)then
goto 1000
end if
end do
close(12)
When I run the above as a standalone program it is OK, but when embedded in my DLL and built and run in release mode it crashes on the final read with end-of-file-during-read. In debug mode it runs perfectly so I can't catch the problem.
Any insights greatly appreciated.
Many thanks
Mike
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Details have been left out in the bug report -- details that would need to be provided before attempting to find and fix the bug.
Missing details: how is the exported entry point of the DLL called, what are the contents of the data file, etc. What was the "small modification" that was performed?
How can one decide that it is the use of release mode and not the small modification that cause the DLL call to malfunction?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, I was trying to keep it simple. The modification I mentioned was trivial and in an unrelated part of the program. I think the real difference now is the fact that prior to the modification the build had been done with a much older version of the Fortran compiler (parallel studio composer I think it was called) whereas the rebuild has been done with Intel Fortran Compiler 2023.1.
In the DLL (far from trivial) is a loop that writes an unformatted scratch file, then later another loop that reads the same file. When I found that the read (in release mode, but not debug mode) now fails on the last line of the file, I created a formatted text file of the same data to try to see what was going on. The behaviour was exactly the same - end-of-file-during-read on the attempt to read the final line.
Here are the final four lines of the data file:
0.49245921 280.70175171 9
18.22099073 2947.36839294 6
6.89442892 1263.15788269 1
278.73191220 39999.99961853 6
The code I posted yesterday reads them perfectly well when run as an independent program, but not when embedded in the DLL in release mode.
The DLL is called like this:
!Get handle of the Nwtable dll
hlb = loadlibrary("Nwtable.dll"C)
if(hlb==0)then
call WinErr(hDlg,'DlgNwtable/NwtDlgProc')
iret = EndDialog(hDlg,TRUE) !Exit dialog
NwtDlgProc = 1
return
end if
!Get address of the Nwtable function
Nwtaddr = getprocaddress(hlb,"NWTABLE"C)
if(Nwtaddr==0)then
call WinErr(hDlg,'DlgNwtable/NwtDlgProc')
iret = freelibrary(hlb)
iret = EndDialog(hDlg,TRUE) !Exit dialog
NwtDlgProc = 1
return
end if
call rtn_nwtable(.....lots of arguments.....)
iret = freelibrary(hlb)
and the DLL's compiler directive is:
!DEC$ ATTRIBUTES DLLEXPORT::NWTABLE
Any insights greatly appreciated.
Many thanks
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Check to see if you are experiencing an optimization issue.
Select Release Build, however, set optimization to None (/O0).
If that works, then you are (likely) experiencing an optimization issue.
You can then experiment with /O1 (O2 is default release mode).
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page