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

deallocate and memory issues

jaureus
Beginner
713 Views

I am having problems with the deallocate and allocate aspects of part of my ifort FORTRAN code. in particular, i think that the issue has to do with memory allocation from a search on my error message on the web. The error message talks about invalid pointers, however, I am not using any pointers in my program. I have also posted this question on http://stackoverflow.com

After completing iteration # 2 of my f loop (see below), the program crashes orrather sometimes it crashes and sometimes it just freezes up. I am confident that this is the point where the bug is. as the program runs up to this point.

I have subroutines not shown but since they work for other simulation combinations, I am reasonably confident that they are not the problem. I am using deallocate and allocate in other places within the program (successfully) so I am surprised that it is not working here.

I am only showing part of the program for ease of reading. in particular, I have removed my calls to the subroutines that I wrote. I hope that i have provided sufficient info for you programmers to help me figure out the problem. if not please specify what other info you want and I will be happy to comply. I have compiled the program using various compiler options and have fixed some bugs and removed any warnings.


I have read another post on this topic here from 2008.

compiler options

ifort -free -check -traceback -o adatptmultistage1new.out adatptmultistage1new.f90


At this point, however, the compiler options do not give me any more info.

here is a sample of the code


allocate(poffvect(1:6))

allocate(phi1out(1:1))

allocate(phi2out(1:1))

allocate(phi1outs1(1:1))

allocate(phi2outs1(1:1))

dummy allocation

allocate(phi1outind(1:1))

allocate(phi2outind(1:1))

allocate(phi1outinds1(1:1))

allocate(phi2outinds1(1:1))

do e = 1, 6

print *,"e", e

do f = 1, 3

print *,"f", f, iteratst1(f), trim(filenumcharimp)


!fails here approximately

deallocate(phi1outinds1, STAT = AllocateStatus)

if (AllocateStatus /= 0) stop "Error during deallocation of phi1outinds1"

print *, "Allocatestatus of phi1outinds1 is", AllocateStatus

deallocate(phi2outinds1, STAT = AllocateStatus)

print *, "DeAllocatestatus of phi1outinds2 is", AllocateStatus

if (AllocateStatus /= 0) stop "Error during deallocation of phi2outinds1"

print *, "we deallocate f loop ok", iteratst1(f)

allocate(phi1outinds1(1:iteratst1(f)), STAT = AllocateStatus)

if (AllocateStatus /= 0) stop "Error during allocation of phi1outinds1"

allocate(phi2outinds1(1:iteratst1(f)), STAT = AllocateStatus)

if (AllocateStatus /= 0) stop "Error during deallocation of phi1outinds1"

end do

end do

output

e 1

f 1 5000 43

DeAllocatestatus of phi1outinds1 is 0

DeAllocatestatus of phi1outinds2 is 0

we deallocate f loop ok 5000

f loop done 1

f 2 10000 43

Allocatestatus of phi1outinds1 is 0

DeAllocatestatus of phi1outinds2 is 0

we deallocate f loop ok 10000

f loop done 2

f 3 15000 43

Allocatestatus of phi1outinds1 is 0

error message

*** glibc detected *** ./adatptmultistage1new.out: munmap_chunk(): invalid pointer: 0x0000000000d3ddd0 ***

======= Backtrace: =========

/lib/libc.so.6(+0x77806)[0x7f5863b7b806]

. /adatptmultistage1new.out[0x43247c]

. /adatptmultistage1new.out[0x404368]

./adatptmultistage1new.out[0x4031ec]

/lib/libc.so.6(__libc_start_main+0xfd)[0x7f5863b22c4d]

. /adatptmultistage1new.out[0x4030e9]

======= Memory map: ========

00400000-004d4000 r-xp 00000000 08:03 9642201

/home/jgold/smwcv/error_infect/test/surfaces/multistage/adaptonly/adatptmultistage1new.out

006d4000-006dc000 rw-p 000d4000 08:03 9642201

[rest of error message not shown for brevity]

7fffb004d000-7fffb00bc000 rw-p 00000000 00:00 0 [stack]

7fffb01d7000-7fffb01d8000 r-xp 00000000 00:00 0 [vdso]

ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]

Aborted

0 Kudos
3 Replies
Steven_L_Intel1
Employee
713 Views
You have the classic symptom of data corruption. Unfortunately, you don't see the effect until you later try to do an allocate or deallocate. The error you're getting is a result of the memory management library's data structures being corrupted, probably by some code earlier in your program.

I would first suggest you rebuild with "-warn interface" added to the existing options. If that doesn't show a problem, try downloading a free trial of Intel Inspector XE and have it run a memory errors analysis of your code.

Another thing you can try is to selectively disable parts of the code prior to where the error occurs, trying to find out which operation, when left in, triggers the error. This can be a time-consuming effort.

Without a buildable and runnable source for us to try, it's impossible to provide you detailed help.
0 Kudos
jaureus
Beginner
713 Views

thank you for your advise

I have also tried with: ifort -free -O2 -stand f03 -check bounds -traceback -warn all -fstack-protector -assume protect_parens -implicitnone -o adatptmultistage1new.out adatptmultistage1new.f90

with no luck. I do not get any more info than before. I am attempting to modify my code to use a module. I don't believe that that will solve the problem but it will clean up my code slightly.


Quoting Steve Lionel (Intel)

Without a buildable and runnable source for us to try, it's impossible to provide you detailed help.


If I were to provide you with my entire code or at least the main program with a couple of the subroutines would you think that you could do more and if so where do I attach files.

0 Kudos
Steven_L_Intel1
Employee
713 Views
You would have to provide a complete program that demonstrates the problem. You could create a .tar.gz and attach it - see my signature below for instructions.
0 Kudos
Reply