Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is backtrace and memory map after executing the C program

Tags:

c

I encountered following after running program correctly and getting accurate results but I don't understand them.

glibc detected *** ./programa: double free or corruption (out): 0x089300a0 ***

======= Backtrace: =========
/lib/libc.so.6[0x8f8c65]
/lib/libc.so.6(cfree+0x59)[0x8fcc59]
./programa[0x804880a]
/lib/libc.so.6(__libc_start_main+0xdc)[0x8a4ebc]
./programa[0x80483e1]
======= Memory map: ========
00870000-0088b000 r-xp 00000000 08:04 1384259    /lib/ld-2.5.so
0088b000-0088c000 r-xp 0001a000 08:04 1384259    /lib/ld-2.5.so
0088c000-0088d000 rwxp 0001b000 08:04 1384259    /lib/ld-2.5.so
0088f000-009e6000 r-xp 00000000 08:04 1384270    /lib/libc-2.5.so
009e6000-009e8000 r-xp 00156000 08:04 1384270    /lib/libc-2.5.so
009e8000-009e9000 rwxp 00158000 08:04 1384270    /lib/libc-2.5.so
009e9000-009ec000 rwxp 009e9000 00:00 0
00ab3000-00abe000 r-xp 00000000 08:04 1384276    /lib/libgcc_s-4.1.2-20080825.so.1
00abe000-00abf000 rwxp 0000a000 08:04 1384276    /lib/libgcc_s-4.1.2-20080825.so.1
00ddb000-00ddc000 r-xp 00ddb000 00:00 0          [vdso]
08048000-08049000 r-xp 00000000 00:17 8620696    /users/c//programa
08049000-0804a000 rw-p 00000000 00:17 8620696    /users/c/programa
08930000-08951000 rw-p 08930000 00:00 0          [heap]
b7fcd000-b7fcf000 rw-p b7fcd000 00:00 0
b7fd8000-b7fda000 rw-p b7fd8000 00:00 0
bfe6f000-bfe84000 rw-p bffe9000 00:00 0          [stack]

Aborted
like image 912
Learner Avatar asked Oct 05 '22 00:10

Learner


1 Answers

It is a crash. To solve this u can follow one of the following approaches.

Use a debugger like GDB to run your program and use backtrace functionality to figure out the crashing function.

Or

Review your code for double free. (May be the code where you have written to free resources. Because you mentioned that you are getting the accurate results.)

Or

Use -Xlinker -Map=output.map option with gcc while compiling your program. This will generate a map file for the executable which has all function addresses. You can map the faulting instruction address or the stack trace to find the function which is causing the crash.

like image 198
CCoder Avatar answered Oct 11 '22 00:10

CCoder