Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Yahoo!, DotBot

Members: 0
Guests: 14
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Coding » Valgrind
Forum Rules | Mark all | Recent Posts

Valgrind
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 15, 2010, 5:57 am
Go to the top of the page
Go to the bottom of the page

Keirath
Magician
GroupMembers
Posts144
JoinedJan 24, 2008

Anyone able to give some tips on using valgrind to find memory leaks? Or a good guide on using it?
       
Post is unread #2 Mar 15, 2010, 1:10 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

The only tips I can give you is that you're going to get some errors about uninitialized varibles in deflate() because of the way zlib is written, that it's intentional, and that I've found no way to suppress the errors as of yet. And to be clear, I mean things like:

==25109== Conditional jump or move depends on uninitialised value(s)
==25109==    at 0x4C28483: memcpy (mc_replace_strmem.c:77)
==25109==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==25109==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==25109==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==25109==    by 0x535C1B: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1677)
==25109==    by 0x5357A7: flush_buffer(descriptor_data*, bool) (comm.cpp:1554)
==25109==    by 0x53319D: game_loop() (comm.cpp:856)
==25109==    by 0x53205E: main (comm.cpp:474)
==25109== 
==25109== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- c
==25109== 
==25109== Conditional jump or move depends on uninitialised value(s)
==25109==    at 0x4C28498: memcpy (mc_replace_strmem.c:402)
==25109==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==25109==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==25109==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==25109==    by 0x535C1B: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1677)
==25109==    by 0x5357A7: flush_buffer(descriptor_data*, bool) (comm.cpp:1554)
==25109==    by 0x53319D: game_loop() (comm.cpp:856)
==25109==    by 0x53205E: main (comm.cpp:474)
==25109== 
==25109== Conditional jump or move depends on uninitialised value(s)
==25109==    at 0x4C284E5: memcpy (mc_replace_strmem.c:402)
==25109==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==25109==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==25109==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==25109==    by 0x535C1B: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1677)
==25109==    by 0x5357A7: flush_buffer(descriptor_data*, bool) (comm.cpp:1554)
==25109==    by 0x53319D: game_loop() (comm.cpp:856)
==25109==    by 0x53205E: main (comm.cpp:474)
==25109== 
==25109== Use of uninitialised value of size 8
==25109==    at 0x4C28504: memcpy (mc_replace_strmem.c:402)
==25109==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==25109==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==25109==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==25109==    by 0x535C1B: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1677)
==25109==    by 0x5357A7: flush_buffer(descriptor_data*, bool) (comm.cpp:1554)
==25109==    by 0x53319D: game_loop() (comm.cpp:856)
==25109==    by 0x53205E: main (comm.cpp:474)


Other than that, pay attention to the line numbers and the errors it spits out. Once you get the hang of it, it becomes infinitely easier to work with. Stealing the cleanup_memory() stuff from will aid in finding your leak as well, because it will clean most things out of memory at shutdown and allow you to see where things are being left in memory.
       
Post is unread #3 Mar 15, 2010, 4:15 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

You need a suppression file to stop Valgrind from reporting those.

The one I use is called vg_suppress.supp, and its contents are:

{
   libz.so.1.2.3
   Memcheck:Cond
   obj:/usr/lib/libz.so.1.2.3
}


The 1.2.3 part needs to match up to your installed library version for zlib.

This is how I call up Valgrind:

valgrind -v --tool=memcheck --leak-check=yes --show-reachable=yes --db-attach=yes --db-command="gdb -nw %f %p" --num-callers=10 --track-fds=yes --suppressions=../src/vg_suppress.supp ../src/afkmud 9500

You may or may not want all of the switches I use, but the suppressions one is the important bit for silencing zlib errors.
       
Post is unread #4 Apr 13, 2010, 7:10 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

So I'm back to fooling with Valgrind trying to do a bit of cleanup on SW:TSW and because I got tired of ignoring those errors with zlib I decided to double check the suppressions file, and it look slike:

{
    libz.so.1.2.3.3
    Memcheck:Cond
    obj:/usr/lib/libz.so.1.2.3.3
}


And I'm still getting:
Tue Apr 13, 2010 10:06:31 PM EDT :: IMC: Connected to Server02. Network ID: MudBytes
Tue Apr 13, 2010 10:06:34 PM EDT :: Loading Account: Kayle
Tue Apr 13, 2010 10:06:35 PM EDT :: Loading player data for: Kayle (11K)
==15669== Conditional jump or move depends on uninitialised value(s)
==15669==    at 0x4C28483: memcpy (mc_replace_strmem.c:77)
==15669==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==15669==    by 0x53C2D2: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1720)
==15669==    by 0x53BE5E: flush_buffer(descriptor_data*, bool) (comm.cpp:1597)
==15669==    by 0x53981A: game_loop() (comm.cpp:895)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669== 
==15669== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- c
==15669== 
==15669== Conditional jump or move depends on uninitialised value(s)
==15669==    at 0x4C28498: memcpy (mc_replace_strmem.c:402)
==15669==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==15669==    by 0x53C2D2: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1720)
==15669==    by 0x53BE5E: flush_buffer(descriptor_data*, bool) (comm.cpp:1597)
==15669==    by 0x53981A: game_loop() (comm.cpp:895)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669== 
==15669== Conditional jump or move depends on uninitialised value(s)
==15669==    at 0x4C284E5: memcpy (mc_replace_strmem.c:402)
==15669==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==15669==    by 0x53C2D2: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1720)
==15669==    by 0x53BE5E: flush_buffer(descriptor_data*, bool) (comm.cpp:1597)
==15669==    by 0x53981A: game_loop() (comm.cpp:895)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669== 
==15669== Use of uninitialised value of size 8
==15669==    at 0x4C28504: memcpy (mc_replace_strmem.c:402)
==15669==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==15669==    by 0x53C2D2: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1720)
==15669==    by 0x53BE5E: flush_buffer(descriptor_data*, bool) (comm.cpp:1597)
==15669==    by 0x53981A: game_loop() (comm.cpp:895)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669== 
==15669== Use of uninitialised value of size 8
==15669==    at 0x4C2850D: memcpy (mc_replace_strmem.c:402)
==15669==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==15669==    by 0x53C2D2: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1720)
==15669==    by 0x53BE5E: flush_buffer(descriptor_data*, bool) (comm.cpp:1597)
==15669==    by 0x53981A: game_loop() (comm.cpp:895)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669== 
==15669== Use of uninitialised value of size 8
==15669==    at 0x4C28564: memcpy (mc_replace_strmem.c:402)
==15669==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==15669==    by 0x53C2D2: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1720)
==15669==    by 0x53BE5E: flush_buffer(descriptor_data*, bool) (comm.cpp:1597)
==15669==    by 0x53981A: game_loop() (comm.cpp:895)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669== 
==15669== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
==15669==    at 0x5EDCFF5: send (in /lib/libc-2.9.so)
==15669==    by 0x53C36D: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1732)
==15669==    by 0x53BE5E: flush_buffer(descriptor_data*, bool) (comm.cpp:1597)
==15669==    by 0x53981A: game_loop() (comm.cpp:895)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669==  Address 0x76880b4 is 4 bytes inside a block of size 4,396 alloc'd
==15669==    at 0x4C25684: calloc (vg_replace_malloc.c:397)
==15669==    by 0x5D6CB2: compressStart(descriptor_data*) (mccp.cpp:122)
==15669==    by 0x53B5C3: read_from_buffer(descriptor_data*) (comm.cpp:1449)
==15669==    by 0x539495: game_loop() (comm.cpp:824)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669== 
==15669== Conditional jump or move depends on uninitialised value(s)
==15669==    at 0x4C28489: memcpy (mc_replace_strmem.c:80)
==15669==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==15669==    by 0x53C2D2: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1720)
==15669==    by 0x552E79: pager_output(descriptor_data*) (comm.cpp:7107)
==15669==    by 0x539789: game_loop() (comm.cpp:887)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669== 
==15669== Conditional jump or move depends on uninitialised value(s)
==15669==    at 0x4C28590: memcpy (mc_replace_strmem.c:402)
==15669==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==15669==    by 0x53C2D2: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1720)
==15669==    by 0x552E79: pager_output(descriptor_data*) (comm.cpp:7107)
==15669==    by 0x539789: game_loop() (comm.cpp:887)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669== 
==15669== Use of uninitialised value of size 8
==15669==    at 0x4C285BC: memcpy (mc_replace_strmem.c:402)
==15669==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==15669==    by 0x53C2D2: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1720)
==15669==    by 0x552E79: pager_output(descriptor_data*) (comm.cpp:7107)
==15669==    by 0x539789: game_loop() (comm.cpp:887)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669== 
==15669== Use of uninitialised value of size 8
==15669==    at 0x4C285C4: memcpy (mc_replace_strmem.c:402)
==15669==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==15669==    by 0x53C2D2: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1720)
==15669==    by 0x552E79: pager_output(descriptor_data*) (comm.cpp:7107)
==15669==    by 0x539789: game_loop() (comm.cpp:887)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669== 
==15669== Use of uninitialised value of size 8
==15669==    at 0x4C28615: memcpy (mc_replace_strmem.c:402)
==15669==    by 0x4E313B9: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E33156: (within /lib/libz.so.1.2.3.3)
==15669==    by 0x4E318EF: deflate (in /lib/libz.so.1.2.3.3)
==15669==    by 0x53C2D2: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1720)
==15669==    by 0x552E79: pager_output(descriptor_data*) (comm.cpp:7107)
==15669==    by 0x539789: game_loop() (comm.cpp:887)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669== 
==15669== Syscall param socketcall.sendto(msg) points to uninitialised byte(s)
==15669==    at 0x5EDCFF5: send (in /lib/libc-2.9.so)
==15669==    by 0x53C36D: write_to_descriptor(descriptor_data*, char const*, int) (comm.cpp:1732)
==15669==    by 0x53BE5E: flush_buffer(descriptor_data*, bool) (comm.cpp:1597)
==15669==    by 0x552EEA: pager_output(descriptor_data*) (comm.cpp:7117)
==15669==    by 0x539789: game_loop() (comm.cpp:887)
==15669==    by 0x5386DB: main (comm.cpp:513)
==15669==  Address 0x76880ee is 62 bytes inside a block of size 4,396 alloc'd
==15669==    at 0x4C25684: calloc (vg_replace_malloc.c:397)
==15669==    by 0x5D6CB2: compressStart(descriptor_data*) (mccp.cpp:122)
==15669==    by 0x53B5C3: read_from_buffer(descriptor_data*) (comm.cpp:1449)
==15669==    by 0x539495: game_loop() (comm.cpp:824)
==15669==    by 0x5386DB: main (comm.cpp:513)
Tue Apr 13, 2010 10:07:03 PM EDT :: Kayle returns from beyond the void.


Any time I log in.

I'm using:
cd ../area
valgrind -v --tool=memcheck --leak-check=yes --show-reachable=yes --db-attach=yes --num-callers=10 --track-fds=yes --suppressions=../src/vg_suppress.supp ../src/swtsw 2075

to invoke valgrind. So.. I dunno why I'm still getting them, but I am. Maybe it's pointing at the wrong location for the lib? I'm out of ideas, but I'm really tired of seeing the damn things.

       
Post is unread #5 Apr 13, 2010, 7:24 pm
Go to the top of the page
Go to the bottom of the page

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

Try adding --gen-suppressions=all to the valgrind options, it should tell you exactly what to put in the supressions file.
       
Post is unread #6 Apr 13, 2010, 7:42 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Alright. So I took Keb's advice. Ran it with --gen-suppressions=all, added the suppressions it spit out to the suppressions file, and I'm STILL getting the damned errors.
       
Post is unread #7 Apr 15, 2010, 7:59 am
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

What does the suppression file look like now?
       
Post is unread #8 Apr 15, 2010, 8:41 am
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Don't know. Had server issues. Issues of the kind that require a fresh install of the OS. I've only just gotten everything back up and running about 9am this morning. And there are still a few quirks to work out. I'll have to try with the latest version of Ubuntu and valgrind after I get things all nice and settled again.
       
Pages:<< prev 1 next >>