Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » valgrind reporting 1000000 still reachable blocks at the end of my program

This thread is locked; no one can reply to it. rss feed Print
valgrind reporting 1000000 still reachable blocks at the end of my program
Michael Taboada
Member #14,161
March 2012

Hi,
I'm having trouble with my programs I'm writing with allegro, namely with valgrind reporting tons of still reachable blocks at the end of my program run.
I am using allegro 5.0.11 on arch linux, and for some reason it says that where some of the blocks start are al_create_display, though I'm pretty much 100% certain I'm destroying the display, and I'm guessing if it's not being destroyed for some reason, then the subsystems are not being uninstalled, which could cause this.
You can find my programs in https://github.com/2mb-solutions/horseshoes, and https://github.com/2mb-solutions/bash-it.
I've made as much as possible shared throughout the program, and the code under game-kit is probably where you want to look, though the main function does use that code.
Thanks for any help,
-Michael.
P.S. This might have something to do with the error I posted a while back under odd x errors.

SiegeLord
Member #7,827
October 2006
avatar

We fixed a ton of memory leaks from 5.0.11 to 5.1.x. Does Arch come with the unstable packages?

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Michael Taboada
Member #14,161
March 2012

Hi,
I don't think it does, but I can always try compiling them myself.
-Michael.

Peter Hull
Member #1,136
March 2001

Just for you, I installed Allegro 5.0.11 and libspeechd and your code for horseshoes and bash-it and game-kit. This is under Ubuntu.For horseshoes I got a black screen and some background music playing. For bash-it, just the black screen. I couldn't easily figure out what to expect or what was wrong from the code.

Have you tried much simpler programs (i.e. the allegro examples)? If you still get X errors and valgrind reports with those we know it's allegro itself and not your code.

I think we need to sort this out before proceeding.

Pete

Chris Katko
Member #1,881
January 2002
avatar

Just for you, I installed Allegro 5.0.11 and libspeechd and your code for horseshoes and bash-it and game-kit. This is under Ubuntu.For horseshoes I got a black screen and some background music playing. For bash-it, just the black screen. I couldn't easily figure out what to expect or what was wrong from the code.

Wow. You really deserve a hand shake for going through that much effort.

I bought you a Reddit Silver:

http://i.imgur.com/wMXXlHN.jpg

(Also, if you actually want Reddit gold, PM me your account and I'll buy you one.)

Quote:

Have you tried much simpler programs (i.e. the allegro examples)? If you still get X errors and valgrind reports with those we know it's allegro itself and not your code.

This, a thousand times this. For future reference, Michael, Peter is hitting the nail on the head when it comes to memory leaks from a library. Always check the example code because it will (usually) be bug free. (Which means it's something you're doing.)

If the example fails, then you've got a simple, succinct piece of code that demonstrates the problem that everyone can easily check so you don't have to chop up your own program to recreate the bug just to demonstrate it.

I once thought I found an Allegro bug with putpixel. It turned out I ended up having a very obscure uninitialized variable issue that caused an problem very far away and only showed up in Allegro functions. It wasn't Allegro at all. The point here is that your code can make it look like Allegro is the problem if you give Allegro bad data to start with. So that's what we're trying to rule out here.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Peter Hull
Member #1,136
March 2001

I've done a bit more on this. For me, valgrind also reports a lot of stuff, virtually all of which (AFAICS) comes from the graphics driver. The next step would to be to write the suppression file for these and see what's left.

If you can go to 5.1, I would recommend that because it's better in many ways as SiegeLord says. Although it's classified as 'unstable' that just means liable to change rather than buggy. And I don't think it's liable to change much at this time.

Finally, on bash-it, it seems to me that you aren't calling dynamic_menu::set_font anywhere, so nothing is being printed on screen because font is NULL. Is the code on github the same as what you're working with?

Cheers,
Pete

Bruce Pascoe
Member #15,931
April 2015
avatar

I think we need to drop the "unstable" moniker, it seems to scare users away unnecessarily. In my experience 5.1 has actually been more reliable than 5.0, which is why I made the plunge for minisphere early on. In fact most of the bugfix work lately seems to go directly into 5.1, with only some of those fixes being backported.

SiegeLord
Member #7,827
October 2006
avatar

There'll be a 5.2 release soonish to resolve this stable/unstable conundrum ;).

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Michael Taboada
Member #14,161
March 2012

Hi all,
I will look into the allegro examples, and compiling with allegro 5.1. As for the reason the text isn't being printed on screen, it's mainly meant to be an audio game, which is mainly going to be played by blind people. That and, as i'm blind myself, I'm not knowledgable in what fonts are good fonts, and royalty free, etc.
Thanks,
-Michael.

Peter Hull
Member #1,136
March 2001

OK, let us know how you get on. I'm not sure I can be of much help, unfortunately.
Pete

SiegeLord
Member #7,827
October 2006
avatar

I just ran horseshoes through valgrind and, after supressing a whole bunch of fglrx errors (see the attached suppression file) pretty much every remaining error was not Allegro's fault!

One Allegro-related leak in your code is this piece of code in game-kit/allegro_stuff/sound.cpp:

s = al_load_sample(((string)(al_path_cstr(al_get_standard_path(ALLEGRO_RESOURCES_PATH), '/'))+file).c_str());

You actually need to free the return value of al_get_standard_path, like so:

ALLEGRO_PATH* path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
s = al_load_sample(((string)
(al_path_cstr(path, '/'))+file).c_str());
al_destroy_path(path);

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Go to: