Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Memory leaks and segmentation fault when allocating unlimited polymorphic variable

Olsen__Oystein
Beginner
803 Views
I have attached a small program with relevant comments that demonstrate the issues. This happens with version 12.1 on opensuse 11.4. Here is a small summary of what I am seeing:

The following works in the main program, but it fails if I send vct to a subroutine and use the same allocate statement.

TYPE(Vector) :: vct
CLASS(*) :: v

ALLOCATE(v, SOURCE=vct)
DEALLOCATE(v)

However, it is possible to do


ALLOCATE(Vector::v)
SELECT TYPE (v)
TYPE IS (Vector)
v = vct
END SELECT
DEALLOCATE(v)

But, this causes a memory leak.



0 Kudos
3 Replies
Steven_L_Intel1
Employee
803 Views
Thanks - we'll take a look.
0 Kudos
Steven_L_Intel1
Employee
803 Views
I can see two problems.

First, in alloc_v, when v is deallocated, v%v is not being deallocated. Why this doesn't work here where it does in the main program I don't know. An explicit deallocate of v%v inside the select block is a workaround - but clearly this code isn't exactly representative of your application as the value of v is never used outside the routine.

The second problem in alloc_source_v is that the allocate with SOURCE= is not filling in v%v properly. Again, why this should fail when it worked in the main program, I don't know.

I didn't quite understand your comment about the "hang", but I am pretty sure that the above two issues are relevant.

Escalated as issue DPD200174103.
0 Kudos
Steven_L_Intel1
Employee
803 Views
Both of the problems have been fixed. The first problem will be fixed in update 9. The second problem will be fixed in a future release.
0 Kudos
Reply