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

Run-Time Check Failure #2 - Stack around the variable '.T474_' was corrupted.

Mark_I_1
Beginner
1,398 Views

Hi,

I am using Intel Fortran XE 2016 edition and VS2015 to compile and test an application (in debug) that is written in C++ with Fortran libraries and I am getting the message:

'Run-Time Check Failure #2 - Stack around the variable '.T474_' was corrupted.'

I don't have any variables named T474_! I've found a few other issues with stack corruption where it mentions a variable that exists but I am stuck on this. The Fortran code was ported from CVT a few months ago and I'm still trying to get it to work reliably.

The subroutine that is giving this error is attached as well as the common block for the tol structure.

Any suggestions?

Note: The subroutine is in a Fortran DLL and the calls to get_double and put_double are callbacks into the application (C++ MFC application).

0 Kudos
3 Replies
Steven_L_Intel1
Employee
1,398 Views

The variable named is a temporary variable created by the generated code. Something is writing to memory outside of where it should, and the stack near where .T474_ was allocated got corrupted. You haven't presented enough information to analyze the problem (not even a compilable source), but the source of the error may not even be in this routine.

If you have Intel Inspector XE its memory analysis feature can often locate the source of corruption issues. Otherwise it's a slog in the debugger to find the culprit. Since you remark that this application is still unreliable, that supports the notion of stack corruption.

0 Kudos
Mark_I_1
Beginner
1,398 Views

Thanks Steve,

The software is pretty much a nightmare in terms of modularity so creating a cut down version is a real problem.

I'll try the Intel Inspector first.

If I comment out the contents of this routine I get stack problems in other routines so this supports that somewhere else is corrupting the stack. Guess the get/put_double or one of the routines it calls are the culprits.. time pull up my the sleeves and jump in..

 

Many thanks,

Mark

0 Kudos
FortranFan
Honored Contributor II
1,398 Views

Re: ".. The Fortran code was ported from CVT a few months ago  .." I assume you mean CVF (as in Compaq Visual Fortran) and not CVT.

If so, please see this: https://software.intel.com/en-us/articles/migrating-from-compaq-visual-fortran, especially the section, "Default Calling Conventions Have Changed".  The error "Stack around the variable '.T474_' was corrupted.'" seems to occur (if I remember correctly from legacy client code) with calling convention issues.

0 Kudos
Reply