In my new startrek game I ran into a nasty problem..since I added the communication class I get a segmentation fault in the engine constructor when making the colors needed with al_map_rgb..Could any of you guys take a look at it ?

I'm staring at it for quite some time but I don't see the problem...

It should compile on windows and linux

Thanx in advance

also you have to copy the resources from the debug map to the release map to do a release build.. including resources in both maps was too big.

Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard)Current project: [Star Trek Project ] Join if you want ;-)

If you have a global / singleton that's calling constructors before Allegro gets initialized, it's going to crash.

-----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

So where is it failing inside setup()? I don't see al_map_rgb() in there, but I do see them in TEngine::TEngine. Do you have a stack trace from GDB for the failure? Do any specific debug options / defines cause it to fail?

Also, did anything change recently that started the problem? That is, did they fail the second you started putting them in, or did they fail after you changed something else?

-----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

Like I sayed, the segmentationfault pops up in the engine constructor after a few calls to al_map_rgb.. exactly where the color white is made.. but If you remove that one the next color becomes the problem.. so it probably isn't the true location of the problem

That means some pointer, some where, is thrashing everything and its most likely completely unrelated to the actual al_map_rgb call.

It's likely that if you change the compiling options (debug/optimize levels) the error will jump around to a different line because the overall organization of the game and memory layout will have changed slightly.

Check all pointers. Check all arrays. Check all classes to make sure you're not using a non-pointer version of a derived class in a base class array (because if they're not pointers, the base class constructor/deconstructor never gets called).

Get Valgrind with:

sudo apt-get install valgrind

And run your program with Valgrind. Valgrind is GREAT for finding memory problems because it runs the entire program in a fake (virtual) CPU that is smart enough to know when something inside it is wrong.

Where test is your program name. Valgrind has hundreds of options so it can be daunting at first glance.

[edit] I tried downloading your code but I cannot get it to compile. Clang throws tons of compile errors including missing constants, missing STD namespace, and more. What did you use on Linux to compile it?

-----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

Ik was coding on Windows yesterday, But I built and ran it several times on Linux (ubuntu) using code::blocks (gcc).I had to reinstall ubuntu some time ago so I need to install and setup allegro again. I'll try it tonight.

Edit.. I was missing permissions to run .. errrm

however.. strange thing is I can build on linux.. the debug version runs fine now.. how that is possible the devil may know... the release build gives error 255 however.. stack overflow ? I thought a debug used up more stack than a release

Edit: after some testing with other code I found the version of allegro I was using caused the problem.. I have no idea why but with version 5.0.4 I get the segmentation fault. With version 5.0.1 everything runs fine....it could be that the 5.0.4 version was build wrong somehow since I built that one myself some time ago. The 5.0.1 version is from allegro.cc

Buy why ?

Perhaps one day we will find that the human factor is more complicated than space and time (Jean luc Picard)Current project: [Star Trek Project ] Join if you want ;-)