Jump to content
  • Advertisement
Sign in to follow this  

malloc(): memory corruption

This topic is 3999 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I was working on a game I'm making last night and came across a strange bug after I made lots of small changes to the source code. Whenever I try to start a multiplayer or singleplayer game, the game crashes. I get this output:
*** glibc detected *** ./habit: malloc(): memory corruption: 0x08260128 ***
======= Backtrace: =========
======= Memory map: ========
08048000-0808b000 r-xp 00000000 08:02 1575       /home/foobar/proj/habitIV/habit
0808b000-0808c000 rw-p 00042000 08:02 1575       /home/foobar/proj/habitIV/habit
0808c000-0829d000 rw-p 0808c000 00:00 0          [heap]
b4800000-b4821000 rw-p b4800000 00:00 0 
b4821000-b4900000 ---p b4821000 00:00 0 
b4936000-b6153000 rw-p b4936000 00:00 0 
b6153000-b6154000 ---p b6153000 00:00 0 
b6154000-b6dd6000 rw-p b6154000 00:00 0 
b6dd6000-b70d6000 rw-s 00000000 00:09 2752534    /SYSV00000000 (deleted)
b70d6000-b70f6000 rw-s 00000000 00:09 2719748    /SYSV0056a4d6 (deleted)
b70f6000-b7106000 rw-s 00000000 00:0d 7054       /dev/snd/pcmC0D0p
b7106000-b710f000 r-xp 00000000 08:03 10622      /lib/i686/cmov/libnss_files-2.7.so
b710f000-b7111000 rw-p 00008000 08:03 10622      /lib/i686/cmov/libnss_files-2.7.so
b7111000-b7119000 r-xp 00000000 08:03 10624      /lib/i686/cmov/libnss_nis-2.7.so
b7119000-b711b000 rw-p 00007000 08:03 10624      /lib/i686/cmov/libnss_nis-2.7.so
b711b000-b712f000 r-xp 00000000 08:03 10619      /lib/i686/cmov/libnsl-2.7.so
b712f000-b7131000 rw-p 00013000 08:03 10619      /lib/i686/cmov/libnsl-2.7.so
b7131000-b7133000 rw-p b7131000 00:00 0 
b7133000-b7134000 ---p b7133000 00:00 0 
b7134000-b7934000 rw-p b7134000 00:00 0 
b7934000-b79f5000 r-xp 00000000 08:03 10971      /usr/lib/libasound.so.2.0.0
b79f5000-b79fa000 rw-p 000c0000 08:03 10971      /usr/lib/libasound.so.2.0.0
b7a08000-b7a09000 rw-s 81000000 00:0d 7054       /dev/snd/pcmC0D0p
b7a09000-b7a0a000 r--s 80000000 00:0d 7054       /dev/snd/pcmC0D0p
b7a0a000-b7a0e000 r-xp 00000000 08:03 20994      /usr/lib/libXxf86dga.so.1.0.0
b7a0e000-b7a0f000 rw-p 00004000 08:03 20994      /usr/lib/libXxf86dga.so.1.0.0
b7a0f000-b7a16000 r-xp 00000000 08:03 10620      /lib/i686/cmov/libnss_compat-2.7.so
b7a16000-b7a18000 rw-p 00006000 08:03 10620      /lib/i686/cmov/libnss_compat-2.7.so
b7a18000-b7a19000 r-xp 00000000 08:03 57792      /usr/lib/allegro/4.2.2/alleg-alsamidi.so
b7a19000-b7a1a000 rw-p 00001000 08:03 57792      /usr/lib/allegro/4.2.2/alleg-alsamidi.so
b7a1a000-b7a1e000 r-xp 00000000 08:03 57791      /usr/lib/allegro/4.2.2/alleg-alsadigi.so
b7a1e000-b7a1f000 rw-p 00003000 08:03 57791      /usr/lib/allegro/4.2.2/alleg-alsadigi.so
b7a1f000-b7a24000 r-xp 00000000 08:03 57790      /usr/lib/allegro/4.2.2/alleg-dga2.so
b7a24000-b7a25000 rw-p 00004000 08:03 57790      /usr/lib/allegro/4.2.2/alleg-dga2.so
b7a25000-b7a28000 rw-p b7a25000 00:00 0 
b7a28000-b7a2c000 r-xp 00000000 08:03 18261      /usr/lib/libXdmcp.so.6.0.0
b7a2c000-b7a2d000 rw-p 00003000 08:03 18261      /usr/lib/libXdmcp.so.6.0.0
b7a2d000-b7a2f000 r-xp 00000000 08:03 18247      /usr/lib/libXau.so.6.0.0
b7a2f000-b7a30000 rw-p 00001000 08:03 18247      /usr/lib/libXau.so.6.0.0
b7a30000-b7a34000 r-xp 00000000 08:03 18528      /usr/lib/libXfixes.so.3.1.0
b7a34000-b7a35000 rw-p 00003000 08:03 18528      /usr/lib/libXfixes.so.3.1.0
b7a35000-b7a3c000 r-xp 00000000 08:03 20739      /usr/lib/libXrender.so.1.3.0
b7a3c000-b7a3d000 rw-p 00007000 08:03 20739      /usr/lib/libXrender.so.1.3.0
b7a3d000-b7a3e000 rw-p b7a3d000 00:00 0 
b7a3e000-b7b85000 r-xp 00000000 08:03 10613      /lib/i686/cmov/libc-2.7.so
b7b85000-b7b86000 r--p 00147000 08:03 10613      /lib/i686/cmov/libc
??? I get the same output when I run it in a debugger (gdb). Does anyone know what causes this type of error? I would be REALLY happy if someone could help me out, because right now my program is completely broken because of this stupid issue. Thanks! (If it matters, I am using Linux)

Share this post

Link to post
Share on other sites
That error message means that you have memory corruption affecting the heap data structures. Likely causes are buffer overruns, using a freed pointer, incorrectly pairing new[]/delete or new/delete[], not using a virtual destructor for a base class and so on.

Share this post

Link to post
Share on other sites
By placing cout's at different places in my code, I have narrowed down the line that causes the issue. It's the line for loading the Lua script for the map being loaded, which doesn't make any sense.

Would this type of crash be something that happens when the program hits a certain line (like a segfault does), or is it like a memory leak where the problem builds and then eventually surfaces?

Share this post

Link to post
Share on other sites
That's probably not the line that causes the issues, it's the line where the issue is detected. You probably corrupted the heap sometime before that line, and that line is the first time a heap consistency check was performed since the actual problem.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!