glibc double free or corruption
I'm getting this message and i can't see why.my program creates threads.
valgrind output is this: ==28643== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 37 from 2) ==28643== malloc/free: in use at exit: 13,266 bytes in 32 blocks. ==28643== malloc/free: 1,524 allocs, 1,492 frees, 89,027 bytes allocated. ==28643== For counts of detected errors, rerun with: -v ==28643== searching for pointers to 32 not-freed blocks. ==28643== checked 162,412 bytes. ==28643== ==28643== 24 bytes in 1 blocks are still reachable in loss record 1 of 6 ==28643== at 0x4022AB8: malloc (vg_replace_malloc.c:207) ==28643== by 0x4022BFC: realloc (vg_replace_malloc.c:429) ==28643== by 0x80532DD: (within /bin/ls) ==28643== by 0x804C354: (within /bin/ls) ==28643== by 0x804D25A: (within /bin/ls) ==28643== by 0x804E8C7: (within /bin/ls) ==28643== by 0x407904F: (below main) (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== ==28643== ==28643== 118 bytes in 7 blocks are still reachable in loss record 2 of 6 ==28643== at 0x4022AB8: malloc (vg_replace_malloc.c:207) ==28643== by 0x8053201: (within /bin/ls) ==28643== by 0x8052536: (within /bin/ls) ==28643== by 0x804E522: (within /bin/ls) ==28643== by 0x407904F: (below main) (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== ==28643== ==28643== 312 (72 direct, 240 indirect) bytes in 2 blocks are definitely lost in loss record 3 of 6 ==28643== at 0x4022AB8: malloc (vg_replace_malloc.c:207) ==28643== by 0x41479B2: (within /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== by 0x4148208: __nss_database_lookup (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== by 0x4745FDB: ??? ==28643== by 0x474711C: ??? ==28643== by 0x40F4EEB: getpwuid_r (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== by 0x40F489D: getpwuid (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== by 0x80522C4: (within /bin/ls) ==28643== by 0x804AAFB: (within /bin/ls) ==28643== by 0x804BB2C: (within /bin/ls) ==28643== by 0x804E7F9: (within /bin/ls) ==28643== by 0x407904F: (below main) (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== ==28643== ==28643== 80 bytes in 10 blocks are indirectly lost in loss record 4 of 6 ==28643== at 0x4022AB8: malloc (vg_replace_malloc.c:207) ==28643== by 0x414758B: __nss_lookup_function (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== by 0x4745FFB: ??? ==28643== by 0x474711C: ??? ==28643== by 0x40F4EEB: getpwuid_r (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== by 0x40F489D: getpwuid (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== by 0x80522C4: (within /bin/ls) ==28643== by 0x804AAFB: (within /bin/ls) ==28643== by 0x804BB2C: (within /bin/ls) ==28643== by 0x804E7F9: (within /bin/ls) ==28643== by 0x407904F: (below main) (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== ==28643== ==28643== 160 bytes in 10 blocks are indirectly lost in loss record 5 of 6 ==28643== at 0x4022AB8: malloc (vg_replace_malloc.c:207) ==28643== by 0x4134D0B: tsearch (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== by 0x414754D: __nss_lookup_function (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== by 0x4745FFB: ??? ==28643== by 0x474711C: ??? ==28643== by 0x40F4EEB: getpwuid_r (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== by 0x40F489D: getpwuid (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== by 0x80522C4: (within /bin/ls) ==28643== by 0x804AAFB: (within /bin/ls) ==28643== by 0x804BB2C: (within /bin/ls) ==28643== by 0x804E7F9: (within /bin/ls) ==28643== by 0x407904F: (below main) (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== ==28643== ==28643== 12,812 bytes in 2 blocks are still reachable in loss record 6 of 6 ==28643== at 0x4022AB8: malloc (vg_replace_malloc.c:207) ==28643== by 0x8053326: (within /bin/ls) ==28643== by 0x804E7A0: (within /bin/ls) ==28643== by 0x407904F: (below main) (in /lib/tls/i686/cmov/libc-2.6.1.so) ==28643== ==28643== LEAK SUMMARY: ==28643== definitely lost: 72 bytes in 2 blocks. ==28643== indirectly lost: 240 bytes in 20 blocks. ==28643== possibly lost: 0 bytes in 0 blocks. ==28643== still reachable: 12,954 bytes in 10 blocks. ==28643== suppressed: 0 bytes in 0 blocks. |
Quote:
Code:
system("/bin/ls"); |
Code:
system("/bin/ls"); templist = *ptraddr; *ptraddr = (*ptraddr)->next; free(templist); but now it's solved. Now i get a malloc corruption(fast) for this: while (*ptraddr != NULL) ptraddr = &((*ptraddr)->next); *ptraddr = malloc(sizeof(struct listnode)); (*ptraddr)->a = i; (*ptraddr)->b = j; (*ptraddr)->next = NULL; |
All times are GMT -5. The time now is 07:46 AM. |