c - Peculiar Errors with free -
i debugging project i've been working on while, , have encountered crazy errors involving free
. can't upload code, because there no way tell problem lies (about 2500 lines of code split 22 files), explain know.
to start with, gdb
being used whole debugging process. error seems rise call free
. following error message gdb
, after program exits sigabrt
:
*** error in `application': free(): invalid next size (normal): 0x08052008 *** ======= backtrace: ========= /lib/i386-linux-gnu/libc.so.6(+0x767e2)[0xb7e467e2] /lib/i386-linux-gnu/libc.so.6(+0x77530)[0xb7e47530] application[0x8049aef] application[0x804a8aa] application[0x8048bee] /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0xb7de9935] application[0x8048a51] ======= memory map: ======== 08048000-08050000 r-xp 00000000 00:16 1571817 application 08050000-08051000 r--p 00007000 00:16 1571817 application 08051000-08052000 rw-p 00008000 00:16 1571817 application 08052000-08073000 rw-p 00000000 00:00 0 [heap] b7d9c000-b7db7000 r-xp 00000000 08:01 1309022 /lib/i386-linux-gnu/libgcc_s.so.1 b7db7000-b7db8000 r--p 0001a000 08:01 1309022 /lib/i386-linux-gnu/libgcc_s.so.1 b7db8000-b7db9000 rw-p 0001b000 08:01 1309022 /lib/i386-linux-gnu/libgcc_s.so.1 b7dce000-b7dd0000 rw-p 00000000 00:00 0 b7dd0000-b7f7d000 r-xp 00000000 08:01 1308997 /lib/i386-linux-gnu/libc-2.17.so b7f7d000-b7f7f000 r--p 001ad000 08:01 1308997 /lib/i386-linux-gnu/libc-2.17.so b7f7f000-b7f80000 rw-p 001af000 08:01 1308997 /lib/i386-linux-gnu/libc-2.17.so b7f80000-b7f83000 rw-p 00000000 00:00 0 b7f83000-b7fc4000 r-xp 00000000 08:01 1309045 /lib/i386-linux-gnu/libm-2.17.so b7fc4000-b7fc5000 r--p 00040000 08:01 1309045 /lib/i386-linux-gnu/libm-2.17.so b7fc5000-b7fc6000 rw-p 00041000 08:01 1309045 /lib/i386-linux-gnu/libm-2.17.so b7fd9000-b7fdd000 rw-p 00000000 00:00 0 b7fdd000-b7fde000 r-xp 00000000 00:00 0 [vdso] b7fde000-b7ffe000 r-xp 00000000 08:01 1308973 /lib/i386-linux-gnu/ld-2.17.so b7ffe000-b7fff000 r--p 0001f000 08:01 1308973 /lib/i386-linux-gnu/ld-2.17.so b7fff000-b8000000 rw-p 00020000 08:01 1308973 /lib/i386-linux-gnu/ld-2.17.so bffdf000-c0000000 rw-p 00000000 00:00 0 [stack]
it seems common double-free, yet there more. have tendency set global pointers null
when don't contain anything, if double-freed wouldn't cause error. moreover, application deals data encryption, created 2 functions of own first overwrite memory , call free.
can problem caused reading memory out of bounds? example, if have 64-byte memory block , accidentally try read 65th byte, cause error when calling free? know writing out of bounds, if not immediately, causes error...
i've been trying locate bug day, no success. there tools (apart breaks, step, continue , watches) gdb provides case? can see code in terms of memory allocation , management? example, there way see how memory allocated in position pointed specific pointer?
thank in advance time! :)
this intensly smells corrupted memory management due having overwritten unallocated memory.
you might use valgrind analyse this.
Comments
Post a Comment