468,512 Members | 1,382 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

***glibc detected*** free(): invalid next size (fast): help?

I made a program that finds a minimum spanning tree.

In my main
I created
kruskal k;
and called
k.findMST();

Expand|Select|Wrap|Line Numbers
  1. void kruskal :: findMST(){
  2. int edgesAccepted = 0;
  3. disjoint ds( numVer ); //disjoint set data structure
  4. edge e; //struct containing vertices and weight
  5. int u,v;
  6.  
  7. while( ( edgesAccepted < numVer - 1 ) && !que.empty())
  8. {
  9. //finds mst 
  10. }
  11.  
  12. }
  13.  
After findMST() function ends, i get the following error.



Expand|Select|Wrap|Line Numbers
  1. *** glibc detected *** ./prog2: free(): invalid next size (fast): 0x09de8180 ***
  2. ======= Backtrace: =========
  3. /lib/libc.so.6[0xb36a96]
  4. /lib/libc.so.6(cfree+0x90)[0xb39fb0]
  5. /usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x342a691]
  6. ./prog2[0x804bb15]
  7. ./prog2[0x804bb3f]
  8. ./prog2[0x804bb78]
  9. ./prog2[0x804bc56]
  10. ./prog2[0x804b67b]
  11. ./prog2[0x8049b50]
  12. ./prog2[0x8049565]
  13. /lib/libc.so.6(__libc_start_main+0xdc)[0xae5dec]
  14. ./prog2(__gxx_personality_v0+0x65)[0x8048e91]
  15. ======= Memory map: ========
  16. 00ab3000-00acc000 r-xp 00000000 08:02 196887     /lib/ld-2.5.so
  17. 00acc000-00acd000 r-xp 00019000 08:02 196887     /lib/ld-2.5.so
  18. 00acd000-00ace000 rwxp 0001a000 08:02 196887     /lib/ld-2.5.so
  19. 00ad0000-00c0a000 r-xp 00000000 08:02 196888     /lib/libc-2.5.so
  20. 00c0a000-00c0c000 r-xp 0013a000 08:02 196888     /lib/libc-2.5.so
  21. 00c0c000-00c0d000 rwxp 0013c000 08:02 196888     /lib/libc-2.5.so
  22. 00c0d000-00c10000 rwxp 00c0d000 00:00 0
  23. 00c12000-00c37000 r-xp 00000000 08:02 196958     /lib/libm-2.5.so
  24. 00c37000-00c38000 r-xp 00024000 08:02 196958     /lib/libm-2.5.so
  25. 00c38000-00c39000 rwxp 00025000 08:02 196958     /lib/libm-2.5.so
  26. 0335e000-03369000 r-xp 00000000 08:02 197036     /lib/libgcc_s-4.1.2-20070626.so.1
  27. 03369000-0336a000 rwxp 0000a000 08:02 197036     /lib/libgcc_s-4.1.2-20070626.so.1
  28. 03377000-03457000 r-xp 00000000 08:02 1167049    /usr/lib/libstdc++.so.6.0.8
  29. 03457000-0345b000 r-xp 000df000 08:02 1167049    /usr/lib/libstdc++.so.6.0.8
  30. 0345b000-0345c000 rwxp 000e3000 08:02 1167049    /usr/lib/libstdc++.so.6.0.8
  31. 0345c000-03462000 rwxp 0345c000 00:00 0
  32. 08048000-0804d000 r-xp 00000000 00:1b 31195548   /prog2
  33. 0804d000-0804e000 rwxp 00004000 00:1b 31195548  /prog2
  34. 09de8000-09e09000 rwxp 09de8000 00:00 0
  35. 40000000-40001000 r-xp 40000000 00:00 0          [vdso]
  36. 40001000-4000a000 rw-p 40001000 00:00 0
  37. 4001a000-4001c000 rw-p 4001a000 00:00 0
  38. 40100000-40121000 rw-p 40100000 00:00 0
  39. 40121000-40200000 ---p 40121000 00:00 0
  40. bfd64000-bfd7a000 rw-p bfd64000 00:00 0          [stack]
  41. make: *** [run] Aborted
  42.  
Nov 29 '07 #1
1 18380
RRick
463 Expert 256MB
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.
Dec 4 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Rob | last post: by
27 posts views Thread by Deephay | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.