开发者

How to correct *** glibc detected *** error in the program [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

glibc detected error

Hi, I was executing my project in GNU C++ when i received this error when i pressed an option in the switch case. As rest of the program is executing fine i am left with this error. I don't know what it is and why it occurs. Please explain and guide me as to where i may start to look in my program.

Error Details:

*** glibc detected *** ./test.out: free(): invalid pointer: 0xbfb1c874 ***
======= Backtrace: =========
/lib/libc.so.6[0x55c0f1]
/lib/libc.so.6(cfree+0x90)[0x55fbc0]
./test.out[0x809f855]
./test.out[0x804fbc0]
./test.out[0x804f9bb]
./test.out[0x80502bb]
./test.out[0x805084e]
./test.out[0x8050d07]
/lib/libc.so.6(__libc_start_main+0xdc)[0x508e8c]
./test.out[0x8049981]
=======开发者_JAVA百科 Memory map: ========
004f3000-00631000 r-xp 00000000 08:01 6148422    /lib/libc-2.5.so
00631000-00633000 r-xp 0013e000 08:01 6148422    /lib/libc-2.5.so
00633000-00634000 rwxp 00140000 08:01 6148422    /lib/libc-2.5.so
00634000-00637000 rwxp 00634000 00:00 0 
0078d000-007a7000 r-xp 00000000 08:01 6152013    /lib/ld-2.5.so
007a7000-007a8000 r-xp 00019000 08:01 6152013    /lib/ld-2.5.so
007a8000-007a9000 rwxp 0001a000 08:01 6152013    /lib/ld-2.5.so
007f9000-0081e000 r-xp 00000000 08:01 6148435    /lib/libm-2.5.so
0081e000-0081f000 r-xp 00024000 08:01 6148435    /lib/libm-2.5.so
0081f000-00820000 rwxp 00025000 08:01 6148435    /lib/libm-2.5.so
00b18000-00b23000 r-xp 00000000 08:01 6148439    /lib/libgcc_s-4.1.2-20080825.so.1
00b23000-00b24000 rwxp 0000a000 08:01 6148439    /lib/libgcc_s-4.1.2-20080825.so.1
08048000-080c6000 r-xp 00000000 00:1e 736543     /users/guest10/shashi/Demo/src/test.out
080c6000-080c7000 rwxp 0007e000 00:1e 736543     /users/guest10/shashi/Demo/src/test.out
080c7000-080cc000 rwxp 080c7000 00:00 0 
08d05000-218b1000 rwxp 08d05000 00:00 0          [heap]
b7e00000-b7e21000 rwxp b7e00000 00:00 0 
b7e21000-b7f00000 ---p b7e21000 00:00 0 
b7fab000-b7fac000 rwxp b7fab000 00:00 0 
b7fc4000-b7fc7000 rwxp b7fc4000 00:00 0 
b7fc7000-b7fc8000 r-xp b7fc7000 00:00 0          [vdso]
bfb0b000-bfb21000 rw-p bffe9000 00:00 0          [stack]
Abort

Please Help.. Thanks in Adv


The exact solution can only be provided if you show us the code. The error is however clear. The code frees memory that is not or no longer valid. That means either the address is wrong, because for example of pointer arithmetic being done on the original pointer. Or the pointer has already been freed (double free).


You are most likely trying to free a memory that wasn't dynamically allocated. Maybe you have an unnecessary free or a typo like: free(&buf) instead of free(buf).

Compile your program with -g flag and run it through debugger or memory debugger. That will show you where the error exactly happens.


It looks like you are trying to free an invalid pointer. You can run the program with a memory check program like [Valgrind][1] like so:

valgrind --tool=memcheck --leak-check=full --track-origins=yes --show-reachable=yes --log-file=val.log ./<executable> <parameters>

Look at val.log and you should be able to figure out where your memory leaks occur. Also, you can try and step through the code with gdb/ddd (debuggers). The program will fail at the spot where the segmentation fault occurs. To make the code debuggable, you will need to re-compile your code with the -g flag.

Alternatively, you could post your code here and let the community see where you are going wrong.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜