Compiler gives out a memory error - Don't know what is wrong
Jun 7, 2010 at 1:25pm UTC
Hi,
I am trying to program a numerical routine involving the Gnu Scientific library. Unfortunately I get the following error when trying to free the memory I used for storing a matrix:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
*** glibc detected *** ./getmatrix.o: munmap_chunk(): invalid pointer: 0x09612a50 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(+0x6b591)[0x3da591]
/lib/tls/i686/cmov/libc.so.6(+0x6c80e)[0x3db80e]
/usr/lib/libgsl.so.0(gsl_matrix_complex_free+0x2d)[0x1b6fad]
./getmatrix.o[0x804a632]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0x385bd6]
./getmatrix.o[0x8049171]
======= Memory map: ========
00110000-002e8000 r-xp 00000000 08:15 151341 /usr/lib/libgsl.so.0.14.0
002e8000-002ea000 r--p 001d7000 08:15 151341 /usr/lib/libgsl.so.0.14.0
002ea000-002f2000 rw-p 001d9000 08:15 151341 /usr/lib/libgsl.so.0.14.0
002f2000-0036d000 r-xp 00000000 08:15 179659 /usr/lib/libblas.so.3gf.0
0036d000-0036e000 r--p 0007a000 08:15 179659 /usr/lib/libblas.so.3gf.0
0036e000-0036f000 rw-p 0007b000 08:15 179659 /usr/lib/libblas.so.3gf.0
0036f000-004c2000 r-xp 00000000 08:15 142905 /lib/tls/i686/cmov/libc-2.11.1.so
004c2000-004c3000
004c3000-004c5000 r--p 00153000 08:15 142905 /lib/tls/i686/cmov/libc-2.11.1.so
004c5000-004c6000 rw-p 00155000 08:15 142905 /lib/tls/i686/cmov/libc-2.11.1.so
004c6000-004c9000 rw-p 00000000 00:00 0
004dd000-004fa000 r-xp 00000000 08:15 717 /lib/libgcc_s.so.1
004fa000-004fb000 r--p 0001c000 08:15 717 /lib/libgcc_s.so.1
004fb000-004fc000 rw-p 0001d000 08:15 717 /lib/libgcc_s.so.1
006a4000-006a5000 r-xp 00000000 00:00 0 [vdso]
00bbd000-00ca6000 r-xp 00000000 08:15 145230 /usr/lib/libstdc++.so.6.0.13
00ca6000-00ca7000 ---p 000e9000 08:15 145230 /usr/lib/libstdc++.so.6.0.13
00ca7000-00cab000 r--p 000e9000 08:15 145230 /usr/lib/libstdc++.so.6.0.13
00cab000-00cac000 rw-p 000ed000 08:15 145230 /usr/lib/libstdc++.so.6.0.13
00cac000-00cb3000 rw-p 00000000 00:00 0
00de8000-00e0c000 r-xp 00000000 08:15 152198 /lib/tls/i686/cmov/libm-2.11.1.so
00e0c000-00e0d000 r--p 00023000 08:15 152198 /lib/tls/i686/cmov/libm-2.11.1.so
00e0d000-00e0e000 rw-p 00024000 08:15 152198 /lib/tls/i686/cmov/libm-2.11.1.so
00e43000-00f07000 r-xp 00000000 08:15 132031 /usr/lib/libgfortran.so.3.0.0
00f07000-00f08000 ---p 000c4000 08:15 132031 /usr/lib/libgfortran.so.3.0.0
00f08000-00f09000 r--p 000c4000 08:15 132031 /usr/lib/libgfortran.so.3.0.0
00f09000-00f0a000 rw-p 000c5000 08:15 132031 /usr/lib/libgfortran.so.3.0.0
00f0a000-00f0b000 rw-p 00000000 00:00 0
00fd5000-00ff0000 r-xp 00000000 08:15 1306 /lib/ld-2.11.1.so
00ff0000-00ff1000 r--p 0001a000 08:15 1306 /lib/ld-2.11.1.so
00ff1000-00ff2000 rw-p 0001b000 08:15 1306 /lib/ld-2.11.1.so
08048000-08051000 r-xp 00000000 08:21 189 /media/M-S325/heisenbergV2.0/src/getmatrix.o
08051000-08052000 r--p 00008000 08:21 189 /media/M-S325/heisenbergV2.0/src/getmatrix.o
08052000-08053000 rw-p 00009000 08:21 189 /media/M-S325/heisenbergV2.0/src/getmatrix.o
09612000-09633000 rw-p 00000000 00:00 0 [heap]
b7707000-b770a000 rw-p 00000000 00:00 0
b7720000-b7723000 rw-p 00000000 00:00 0
bfae7000-bfafc000 rw-p 00000000 00:00 0 [stack]
Aborted
I know that at the time the memory should be deallocated, the matrix exists ( I just gave it out the line before). What is wrong?
The error is given out when the programm reaches the line
1 2
gsl_matrix_complex_free(Hamiltonian);
(Hamiltonian is the Matrix)
I uploaded the code to
http://rs622.rapidshare.com/files/396245226/getmatrix.cpp
because I think it is too long to post it here.
Thank you very much for looking!
Topic archived. No new replies allowed.