Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Mystifying problem with a program that I thought had previously been working.

This thread is locked; no one can reply to it. rss feed Print
Mystifying problem with a program that I thought had previously been working.
alexx.
Member #10,925
April 2009

Posted on 02/16/2021

I previously had allegro-5-2-5-0 running under ubuntu 18.04 and everything was working fine, had been for a long time. Hardware problems made it necessary to reload the os.

Made a clean install of ubuntu 20.04, loaded everything back and decided to go for a later allegro, 25.2.6.0. System was set up following: https://github.com/liballeg/allegro_wiki/wiki/Install-Allegro-from-source-on-Ubuntu

Everything seemed fine.

However when I tried running programs that I had been running previously for years they did not behave properly. They appeared to run correctly, to follow the code correctly, but there would very often be spurious output onto the screen. These were big programs with a long history and were not using allegro 5 in the way the designers intended. However they were working. Now even going back to ubuntu 19 and allegro 5-2-5-0 they will not run properly.

I am completely mystified. I have made about the smallest possible program to show up the error. Can someone run this and see if they get a similar result. I cannot find a pattern, key depressions are always correctly detected but sometimes give a garbage screen output, always within the created display area. Sometimes when an error occurs taking a screenshot changes the display ( I mean with the allegro program running between clicking on the screenshot icon and the screenshot window appearing the display window of the allegro program changes ).

Can someone see if they get the same result by compiling the program and running it. It does not seem like a hardware problem, apart from this program everything is fine. Or see in the source code something wrong?

I'm enclosing a couple of screenshots of the error and the source and makefile. The program should receive keyboard characters, display a yellow rectangle and output keyboard codes to the consol for each one. Escape to end.

Alexx

Elias
Member #358
May 2000

It seems to work here (ubuntu 20.10) but hogs a CPU core.

See if adding some al_rest(0.001) calls into your loops or al_wait_next_event instead of al_peek_next_event fixes it, having a busy loop like that always increases the chance of a deadlock or livelock. (Just to help narrow down the problem, next step will be finding the actual deadlock.)

--
"Either help out or stop whining" - Evert

alexx.
Member #10,925
April 2009

Thanks for help. New program uploaded.

I tried putting in two "al_rest(0.001)"as shown, and also tried with 0.002 as well. Both about the same result.

Without the program running I had two processors running at about 15%, and with it running two processors running at about 45%.

More important it didn't help with the display going wrong.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

It looks like your video memory is getting corrupted or overwritten. There may be nothing wrong with your program, but if there is valgrind will probably find it. Learn how to use it. You'll want to try valgrind and helgrind at a minimum (they're subprograms of valgrind).

All you have to do is compile with debugging symbols enabled, and then run your program through valgrind. It will tell you if there are memory problems (valgrind) or threading issues (helgrind).

Edit
al_peek_next_event should not be used in a tight loop. Your coding style is allegro 4 but you're coding in allegro 5. Use a better event loop and use al_wait_for_event instead.

alexx.
Member #10,925
April 2009

Well, since I know this was running successfully until the last few months ( or rather the much bigger programs of which this is a small watered down part ) I ordered a new video card. Just on the chance of fixing the problem, not arrived yet.

I downloaded valgrind and installed it, ran both valgrind and helgrind. Was quite surprised. They both show errors but to be honest I don't understand much of what anything means. But both are complaining. Memory loss and thread problems with me doing nothing during the run except entering an escape key.

I have never looked at the allegro source up 'til but may have to.

I enclose my valgrind and helgrind output.

I spent days a few years ago trying to convert my programs from allegro 4->5 and using the 5 conventions but I just was not able to do it. Nothing to do with gaming and originally running under MSDOS.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Before you go installing a new GPU, try updating your graphics drivers and the libMesa stuff that Ubuntu 20 is using. I probably won't be able to test this unless I install Ubuntu 20.04 in a VM and my bandwidth is rather limited to be downloading multi gigabyte iso images.

As for the valgrind and helgrind output, neither of them indicate anything wrong with your code. The glxGetFBConfig calls seems to be inside a race condition, but that's on Allegro's end. It might contribute to the problem but who knows.

Undefined behavior is undefined, that's how it goes.

But I'm willing to think this could be solved with updated graphics drivers, and or dependencies when building allegro 5 on Ubuntu 20.04.

piccolo
Member #3,163
January 2003
avatar

to me it sounds like your are losing some kinda of event handle in your loop caused by a process over or under shooting of a process that contains more or less of execution steps you assumed it to have when you created/used it in the first place.

something like those microS bugs from back in the day when they change functionality of how different process worked in updates they pushed out.

wow
-------------------------------
i am who you are not am i

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

alexx.
Member #10,925
April 2009

[EDIT]

This post previously [ 6 March ] described another symptom. As there were no responses to it and I have now solved it myself I have just edited it out rather than left it here to avoid confusion.

So just the original problem as stated remains.

Thanks for any help.

Go to: