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

debugging memory access violation on dll function access

Wouter_Engels
Beginner
1,640 Views
I have received a customers dll which should work with my software.
If I run it debug mode it does work well, in release version I get :

forrtl: severe (157): Program Exception - access violation

the dll is called from another dll, which is part of my program.

I suspect there is something wrong in terms of the size of assumed
in- and outputs, specifically when the function I called is returning data to
my program.

How can I go about figuring out what is wrong?

Is there a way to get more diagnostic feedback for this type of error in the release version?
Despite putting diagnostic to full, I don't even get a linenumber. (Which would be useful for
me, as it would confirm that it is indeed on the call to the function in the customers dll that
the access violation occurs.)

Is there some way to check in debug mode the size of the arrays that are returned?

Wouter
0 Kudos
3 Replies
ZlamalJakub
New Contributor III
1,640 Views
I think only way is to debug release version in Visual studio and look at assembler code and check values passed to routine and returned looking into CPU registers and memory.

Other way is to ask provider of dll to put there some debug output (for example to text file) summary of passed parameters and summary of output values. It will be the fastest way.
0 Kudos
DavidWhite
Valued Contributor II
1,640 Views
Have you added the "Generate Traceback Information" /traceback - it is under Run-time. This should give the line number in your code where the error occurs.

David
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,640 Views
Wouter,

The usual cause for memory access errors when calling 3rd party library functions is in not using the proper calling convention or mis-matching arguments (reference verses value, size of integer, BOOL verses LOGICAL).

If the supplier of the library has not provided the FORTRAN interfaces, generally in a .MOD file, then a likely culprit is passing argument by reference or value as opposed to value or reference. Argument size can be in error as well (using integer where dword is required). Add strings in FORTRAN are not NULL terminated.

If the interface .MOD file is not supplied by the vendor, then you must write one for your own purpose and where it correctly specifies the calling convention and arguments. You will have to ascertain what these are from the C++ (or other) API provided by the .DLL documentation.

Jim Dempsey
0 Kudos
Reply