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

Debugger indicates data corruption but the results don't ?

abhimodak
New Contributor I
769 Views
Hi

In the snippet below, the modules basic and derived are not used at all. The compilation is successful; however when stepped in subroutine Technique, the values of Y (and F after allocation) appear "corrutped" in the debugger. {I get Y(1) = 5.6e-45, Y(2) = NaN,a nd Y(3) = 1.5E-33 instead of -1.0. The the print-out of Y shows its correct value (=-1.0).

However, if the modules basic and derived are commented out then the values displayed in the debugger are correct.

Abhi

-----

Module Basic

Implicit None

Type, Abstract :: Parent
Integer :: i
Real :: r
Contains
Procedure(Scheme), Deferred :: Method
End Type Parent

Abstract Interface
Subroutine Scheme(Object, t, S, F)
Import
Class(Parent) :: Object
Real, Intent(IN) :: t
Real, Intent(IN) :: S(:)
Real, Intent(OUT) :: F(:)
End Subroutine Scheme
End Interface
End Module Basic

Module Derived

Use Basic

Implicit None

Type, Extends(Parent) :: Child
Logical :: Something
Procedure(Method), Pointer, Pass(Object) :: Formula
Contains
Procedure, Pass(Object) :: Method
End Type Child

Contains

Subroutine Method(Object, t, S, F)

Implicit None

Class(Child) :: Object

Real, Intent(IN) :: t
Real, Intent(IN) :: S(:)

Real, Intent(OUT) :: F(:)

F = -1.0d0

End Subroutine Method

End Module Derived

Module Collection

Implicit None

Contains

Subroutine Technique(t, Y, tout)

Implicit None

Real, Intent(INOUT) :: t, Y(:)
Real, Intent(IN) :: tout

Real, Allocatable :: F(:)
Integer :: ial

Allocate(F(size(Y)), stat=ial)
print *, Y ! break-point at this line => debugger shows corrupted Y (and F)

End Subroutine Technique

End Module Collection

Program Test

Use Collection

Implicit None

Real :: t, tout
Real :: Y(3)

t = 0.0
Y = -1.0

tout = 1.0

Call Technique(t, Y, tout)

End Program Test
0 Kudos
7 Replies
jimdempseyatthecove
Honored Contributor III
769 Views

Just prior to Call Technique(t, Y, tout) write the size(Y), and value of t, Y, tout
Just inside Technique, prior to allocation, do the same,
Just after allocation write the value of ial
Then write the size(Y), and value of t, Y, tout

Does anything unusual happen? If so, what?

Jim Dempsey


0 Kudos
abhimodak
New Contributor I
769 Views
Hi Jim

I don't think anything unusual happened when I put in those write statements. The printed values are 3, 0.0000000E+00, and 1.000000 for Size(Y), t, and tout. Value of Y is also printed correctly to be -1.000000.

The end result i.e. debugger showing garbage values, happens if:
(1) If I create a new allocatable array Z and pass it instead of Y,
(2) If I pass the dimension N of array (=3) through the subroutine's interface
(3) Create both Y and Z but pass Y (along with the dimension).

and a few other simple variations. In each cases I see garbage values in the debugger albeit they are different.

In case (3) above, Z looks corrupted at the poitn before the call is made while inside Technique Y's first two values are correct but third is garbage.

I am using compiler version 11.1.051 with VS2005 on WinXP64 and I am building a Win32 binary in debug mode.

I tried this snippet with 11.1.046. It shows the same weird behvior; however 11.1.038 works fine. Hope this helps.

Abhi
0 Kudos
jimdempseyatthecove
Honored Contributor III
769 Views

>>Value of Y is also printed correctly to be -1.000000

This indicates the code is correct, but the debug symbol definition for Y is incorrect. It probably generated Y as being the address of the first cell of a rank-1 array as opposed to being the address of an array descriptor to a rank 1 array.

Your sample code should be a reproducible test case for Intel to use. Have you sent this to Intel Premier Support?

Jim
0 Kudos
abhimodak
New Contributor I
769 Views
I believe that Intel will pick it up from here and assign a reference.

Abhi
0 Kudos
Steven_L_Intel1
Employee
769 Views
Issue ID is DPD200142458. The correct behavior mostly returns if you move the unused modules to a separate source file (and compile them there). However, even with this, Y shows up oddly in the debugger inside subroutine Technique - it looks ok in a tooltip, but not in a Watch or Locals window.
0 Kudos
Steven_L_Intel1
Employee
769 Views
I expect the fix for this to appear in 11.1 Update 5, scheduled for mid-February.
0 Kudos
Steven_L_Intel1
Employee
769 Views
Actually, 11.1 Update 6, available now.
0 Kudos
Reply