söndag 17 januari 2010

Valgrind helps finding memory errors

I just want to strike a bell for valgrind - it identifies bad memory writes/reads as well as uninitialized variables in a very nice way!

Installing valgrind is easy, just go

sudo apt-get install valgrind

By starting vsxu like this:

valgrind --track-origins=yes ./vsxu_artiste.bin

Just look at this situation, the GL driver runs some code that uses an unitialized value which could definitely mean problems in some situation:

==12033== Conditional jump or move depends on uninitialised value(s)

==12033== at 0x49C7401: (within /usr/lib/libGLcore.so.180.44)
==12033== Uninitialised value was created by a heap allocation
==12033== at 0x40269EE: operator new(unsigned int) (vg_replace_malloc.c:224)
==12033== by 0x72504DF: create_new_module (in /home/jaw/vsxu/vsxu_0.1.18/_plugins_linux/render.opengl-lib.so)
==12033== by 0x423E2A0: vsx_comp::load_module(module_dll_info*) (vsx_comp.cpp:101)
==12033== by 0x4257B79: vsx_engine::process_message_queue(vsx_command_list*, vsx_command_list*, bool) (vsx_em_comp.h:10)
==12033== by 0x8054321: vsxu_draw::draw() (application.cpp:228)
==12033== by 0x8051C6B: app_draw(int) (application.cpp:316)
==12033== by 0x811AE34: main (main.cpp:286)

It even tells me where I allocated this memory! Awesome!

Inga kommentarer:

Skicka en kommentar