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

Fortran Dll crashed@internal write under IVF8.0 while works under CVF6.x

wu_internet
Beginner
3,819 Views
Dear all,

I am porting a compaq fortran project (version 6.x) over to the intel
fortran compiler (version 8.0). However, crash always happens at the
internal write statement under the intel fortran compiler.

=========
project brief:
=========
The soultion comprises two parts, one is the c++ project, which in charge of
the user interface, the other project is a Fortran Dll project. The Fortran
Dll is invoked by the C++ project. the problem I meet here is every simple,
the C++ project is just a framework of the dialog based mfc win32
application. In the code response to the click OK button, it will invoke the
fortran dll. The Fortran dll is built as the name of TestDll.dll. The core
part of the C++ and Fortran code are shown as follows:


=========
C++ code
=========
...
typedef unsigned int (__stdcall *_FPTR_START_APP) ( void * );
...

if (nResponse == IDOK) ////code corresponding to the click OK
button
{

CString fileName = "abc";
m_hSimDLL = LoadLibrary((LPCTSTR)"TestDll");
FARPROC fPtrStartApp = ::GetProcAddress( m_hSimDLL, "StartApp" );

void* pvSecurity = NULL;
unsigned int* puiThrdAddr = NULL;
m_hThread = (HANDLE) _beginthreadex( pvSecurity, 0,
(_FPTR_START_APP)fPtrStartApp, (void *)(LPCTSTR)fileName.GetBuffer(0), 0,
puiThrdAddr );
...//idle or do something here so that the thread of the fortran Dll will
run and can be debugged.
}

=========
Fortran code
=========
Corresponding Fortran Dll is made of by the following code:

! ---------------------------------------------------------------------
Subroutine StartApp(iAddressStrBuf)

!DEC$ ATTRIBUTES DLLEXPORT::StartApp
!DEC$ ATTRIBUTES ALIAS: 'StartApp'::STARTAPP
!DEC$ ATTRIBUTES VALUE::iAddressStrBuf

integer iAddressStrBuf
integer i
character*32 strTest

i=555

write(strTest,'(i10.10)') i
return
end subroutine StartApp
!----------end of the fortran dll project ----------------------------------

=========
Symnpton
=========
Whenever the internal write statement is invoked, the program will crash and
report the error of access violation occurred.

If there is anyone knows the issue, could you please give me a hand.

=========
Attached
=========
It appears that I can not send the whole project sample files in zip format,
I will send to those who responsed to this email either in person or to the
newsgroup if needed.

Best Regards,

David



0 Kudos
26 Replies
peledrg
Beginner
1,012 Views

Steve,

The FORTRAN compiler is 9.1.028. Two other programmers in our company were having a similar problem with different applications. The other 2 were able to wrap the FORTRAN WRITE with a "C" call. For all of us it used to work in WIndows 2000. But it failed when we installed Windows XP. In some case no code change but only a re-build on XP caused the crash.

Thanks,

Rachel

0 Kudos
Steven_L_Intel1
Employee
1,012 Views
That strengthens my feeling that's a coding error in the application. You have something that is dependent on memory layout. This si not the sort of thing that will reveal itself by general descriptions of the problem - one has to get into the actual application with the debugger and see what is going wrong. What you have done so far amounts to just papering over the problem - it will eventually come back to bite you.

We'd be glad to help if you can provide Intel Premier Support with a complete example that demonstrates the problem.
0 Kudos
peledrg
Beginner
1,012 Views

Steve,

The address that it is crashing is: 0x0C1288A0.

Thanks,

Rachel

0 Kudos
Steven_L_Intel1
Employee
1,012 Views
Well, that doesn't tell me a lot without knowing the other things I asked, but as that is a VERY high address, my guess is that you have something else in your program corrupting memory. Try building with /check:bounds /gen_interfaces /warn:interfaces.
0 Kudos
peledrg
Beginner
1,012 Views

Steve,

My problem was that I was using "debug Mutlithred dll" instead of "Multithres dll". You have mention this problem in 108663of this subject but I have missed it.
I had one of my co-worker read all your responses to this problems and he noticed it.

Thanks again for all your great support.

Rachel

0 Kudos
Steven_L_Intel1
Employee
1,012 Views
You're welcome. I'm glad you found the solution.
0 Kudos
Reply