*** glibc detected *** ./test: free(): invalid pointer: 0x0854d1b4 ***

*** glibc detected *** ./test: free(): invalid pointer: 0x0854d1b4 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(+0x6b591)[0x208591]
/lib/tls/i686/cmov/libc.so.6(+0x6cde8)[0x209de8]
/lib/tls/i686/cmov/libc.so.6(cfree+0x6d)[0x20cecd]
./test[0x804946f]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0x1b3bd6]
./test[0x8048d71]
======= Memory map: ========

0019d000-002f0000 r-xp 00000000 07:00 2730       /lib/tls/i686/cmov/libc-2.11.1.so
002f0000-002f1000 ---p 00153000 07:00 2730       /lib/tls/i686/cmov/libc-2.11.1.so
002f1000-002f3000 r--p 00153000 07:00 2730       /lib/tls/i686/cmov/libc-2.11.1.so
002f3000-002f4000 rw-p 00155000 07:00 2730       /lib/tls/i686/cmov/libc-2.11.1.so
002f4000-002f7000 rw-p 00000000 00:00 0
00470000-0048b000 r-xp 00000000 07:00 17281      /lib/ld-2.11.1.so
0048b000-0048c000 r--p 0001a000 07:00 17281      /lib/ld-2.11.1.so
0048c000-0048d000 rw-p 0001b000 07:00 17281      /lib/ld-2.11.1.so
0070f000-0072c000 r-xp 00000000 07:00 2638       /lib/libgcc_s.so.1
0072c000-0072d000 r--p 0001c000 07:00 2638       /lib/libgcc_s.so.1
0072d000-0072e000 rw-p 0001d000 07:00 2638       /lib/libgcc_s.so.1
007da000-007db000 r-xp 00000000 00:00 0          [vdso]
00b56000-00b75000 r-xp 00000000 07:02 3469       /usr/lib/libjpeg.so.62.0.0
00b75000-00b76000 r--p 0001e000 07:02 3469       /usr/lib/libjpeg.so.62.0.0
00b76000-00b77000 rw-p 0001f000 07:02 3469       /usr/lib/libjpeg.so.62.0.0
08048000-0804a000 r-xp 00000000 07:01 1528       /home/magic/digital--004-01bug/test
0804a000-0804b000 r--p 00002000 07:01 1528       /home/magic/digital--004-01bug/test
0804b000-0804c000 rw-p 00003000 07:01 1528       /home/magic/digital--004-01bug/test
08545000-08566000 rw-p 00000000 00:00 0          [heap]

b7400000-b7421000 rw-p 00000000 00:00 0
b7421000-b7500000 ---p 00000000 00:00 0
b7583000-b75db000 rw-p 00000000 00:00 0
b75db000-b78db000 rw-s e0000000 00:05 2167       /dev/fb0
b78db000-b78dd000 rw-p 00000000 00:00 0
b78eb000-b78ee000 rw-p 00000000 00:00 0
bff1b000-bff30000 rw-p 00000000 00:00 0          [stack]
已放弃


----下面是我从网上搜的一点解释:

These messages generally mean that the heap storage (i.e. malloc) has been corrupted. 

Unfortunately, you won't get much information from the stack dump as to who or what caused this problem. Heap corruption is usually caused by a rogue pointer or buffer overwrite and shows up later in the program execution after the damage has been done.

Valgrind is a good memory checker for these types of problems.

 

测试的方法:
在malloc 后接着就打出来指针的地址
在free之前也打出指针的地址


比较这两个地址是否相同,如果不同就是你指针被改了。


你可能感兴趣的:(*** glibc detected *** ./test: free(): invalid pointer: 0x0854d1b4 ***)