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

Deallocate error in release mode.

klzhang
Beginner
1,059 Views
I use Intel Fortran Compiler 10.1.024 with Visual Studio 2005.

My program has a error message ONLY release mode as attached file.

The message is:
forrtl: severe (173): A pointer passed to DEALLOCATE points to an array that cannot be deaallocated.

I used a lot of dynamic allocate/deallocate arrays, as well as my own type of structure with pointer.

Since I need to analyze my algorithm in terms of computational time, I need to run it in release mode, not only in debug mode.

Thanks for answers.

Kuilin
0 Kudos
8 Replies
Steven_L_Intel1
Employee
1,059 Views
Either you have a bug in your code that is corrupting memory, or there is a bug in the compiler. A test case is needed to determine which it is.
0 Kudos
klzhang
Beginner
1,059 Views
The problem is that I cannot do anything in the release mode. How can I know where (which deallocate code) I had this error in release mode?

Thanks,
Kuilin
0 Kudos
Steven_L_Intel1
Employee
1,059 Views
Turn on the Traceback option (Fortran > Run Time > Generate Traceback Information > Yes), rebuild and run. You should now see a traceback with file name and line number.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,059 Views
As a first resort, try switching on Debug Information Format->"Full" on Properties/Fortran/Debugging for the release configuration. That will enable it to run it under debugger, but it may or may not allow still reproducing the error. The second line of defense would be inserting tracing WRITE statements. Ultimately, there could be a way of "overriding" for_allocate RTL function to get more debugging information, but I'd spare you the details, as it would be among last resorts.


0 Kudos
Steven_L_Intel1
Employee
1,059 Views
Here's something else you can try. Add the attached source to your project. Then, where you want to check for corruption, add:

use Array_Descriptors

to the top of the routine and then call descr_dump(arrayname). For example, this test program:

    program Test
    use array_descriptors

    implicit none

    real, allocatable, target :: a1(:,:)
    real, pointer :: a2 (:,:)
    
    
    allocate (a1(10,5))
    a2 => a1(2:8:2,3:5)
    
    call descr_dump(a1)
    call descr_dump(a2)
    

    end program Test

gives this output:

Dump of descriptor at location 004D60A0
 Base address: 00368D38
 Element size: 4
 A0 offset from base: FFFFFFD4
 Flags: 00000005
        Defined
        Contiguous
 Rank: 2
  Dimension 1: LB 1 Extent 10 Stride 4
  Dimension 2: LB 1 Extent 5 Stride 40

Dump of descriptor at location 004D9540
 Base address: 00368D8C
 Element size: 4
 A0 offset from base: FFFFFFD0
 Flags: 00000003
        Defined
        No Deallocate
 Rank: 2
  Dimension 1: LB 1 Extent 4 Stride 8
  Dimension 2: LB 1 Extent 3 Stride 40

You want to see when the No Deallocate flag gets set.

0 Kudos
klzhang
Beginner
1,059 Views
Hi Steve and Jugoslav,

Thanks for your kind reply.

I did as Steve's suggestion and located the deallocate error array, and fixed it.

The problem is as follow:
I declared a temp pointer type as follow, where the AltAttribute is my own type.
Code:
TYPE(AltAttribute), POINTER :: tempP(:)

I have a condition to allocate tempP.
Code:
if (Old_Size>0) then
ALLOCATE(tempP(AltAtt_Array(it)%PSize),stat=vectorerror)
endif

And at the end of this subroutine, I should deallocate this array and then I use the following statement.

Code:
if(associated(tempP)) DEALLOCATE(tempP)

So the problem happened when the varaible Old_Size =0, since the subroutine did not allocate tempP.

However, the condition if(associated(tempP)) should take care of this situation anyway, which is used to check whether an array is allocated or not and works fine in the debug mode.

Thank you very much.

Kuilin

0 Kudos
Steven_L_Intel1
Employee
1,059 Views
A zero-size array can be allocated and is not the same as an unallocated array. I know that we and some other compilers have had issues with this in the past, but current versions should handle it correctly.
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,059 Views

Kuilin,

Pointer declaration does not initialize to NULL. Add the initializer to your declaration and your code should then work.

TYPE(AltAttribute), POINTER :: tempP(:) => NULL()
Jim Dempsey

					
				
			
			
				
			
			
			
			
			
			
			
		
0 Kudos
Reply