Finding SIGABRT

closed account (oGhfSL3A)
Hello! My code has been crashing with SIGABRT but I don't know where and have know idea what I am doing wrong.

Right now I am getting it at ghInput::addKeyAction line 49: keyActions_.push_back(tempKeyAction);
Which looks okay to me and the exact same code has run fine before.

I have tried commenting out parts of the code and then it will just crash somewhere else, so I am finding it impossible to track down the problem.

I also could not recreate the problem in a simpler example to show here, so apologies for the rather long code.

This is really driving me mad since I have gone through it so many times. Thank you in advance!

code:
https://drive.google.com/folderview?id=0B6XIrWWoN10pfk5oQmFSeHVrOWVLUnhlY2xkME9lWFBJekFmQktQZDNaMmFTN1F4bTlaSWs&usp=sharing
closed account (oGhfSL3A)
No Replies? :(

Ok, I will try to be more specific so you don't have to read a ton of code and just read the relevant parts.
My code was working fine when It was in this state:

https://drive.google.com/folderview?id=0B6XIrWWoN10pfkZDNDhobGZTTTU5cG5kUVNzQWE0emVtRFlUc1FKS1VEMHlVM1Z5U2RkZ3c&usp=sharing

This program has a state machine with two states – gsGame & gsMainMenu and each state has its own input handler – ghInput and initializes input commands – giCommand, which just do something when the user presses, holds or releases a key. Both states initialize a gcmdChangeState that just changes to the other state on pressing the enter key. gsGame also has a gcmdTest that just prints out “command executed” in the terminal. Both states also have their own graphics handler -ghGraphics that stores and updates graphical components – gcGraphical – gComponent. Components are initialized by each states' entity handler - ghEntity. I have created one graphical component in gsGame that is just a magenta square.

Relevant files: gcomponent.h, ghentity.h

From this point I wanted to be able to create and store gcDataModifier objects (gcDataModifier basically stores pointers to a bunch of components and has a method that loops through, updating them with new data) in ghEntity. gcDataModifier is a template class so I gave it a base (so in ghEntity I could store base pointers to them on the heap):

1
2
3
4
5
class gcDataModBase{
public:
    gcDataModBase();
    virtual ~gcDataModBase();
};


Then I made gcDataModifier inherit from it obviously.
At this point the program still runs fine.

Then I add to ghEntity:
 
std::vector<DataModBase*> dataModifiers_;


Now without even using the vector if I run my program It crashes immediately on creation of a graphical component.
And, when I step through it the vector contains 4741426 items with undefined values? I haven't even attempted to use it, why would it contain anything at all? Also, if I just put a single DataModBase pointer in ghEntity the program runs and the input commands work, but the magenta square is not there. It's like creating a pointer to DataModBase invalidates components somehow.

Also, after making the same changes again I'm getting a segfault now.

Crashing code:

https://drive.google.com/folderview?id=0B6XIrWWoN10pfm9VZHdNa3h2R0xLMjBNUmVibG5KRjlSX3JfekkwTWwzTTljMzJmRmxRNW8&usp=sharing
Last edited on
Downloaded your latest and I can't get it to segfault on my machine (Debian Sid, g++ 4.9.2, Qt Creator 3.3.0).

I get a window with a green background and a magenta square in the upper left corner. There is also an xterm window that starts with "in game". Each time the space bar is pressed "executing command" is printed in the xterm. Pressing the enter key prints "in mainmenu". Pressing enter again prints "in game". Tried this numerous times with no segfault.

I put a breakpoint in ghentity.cpp and dataModifiers_ is always empty.

Have you tried cleaning your project and rebuilding?
> No Replies? :(
I'm just lazy to have to download over 5 files
¿is there an easy way to have it all in a zip?
@ne555 - I had a heck of a time with that, too. The following might not be the Google way but it worked.

If you have a google account and are logged in, click on the "Add to Drive" button on the upper right. That copies the directory to your "google drive" space. Click on "Google Drive" on the upper left to go to your drive. Once there you can select the directory, right click and download a zip file.
closed account (oGhfSL3A)
> Have you tried cleaning your project and rebuilding?

Wow that fixed it.
I've never cleaned my project before / known when to use it.

Thank you muchly!
Topic archived. No new replies allowed.