What can cause this crash?
I have a C ++ program (GCC) and when I add one or more int members to an abstract base class, the program starts to crash. In the case at hand, it seems that by adding this member, the member in the derived class gets out of initialization (or gets caught at some point). If I add more members, it starts (not) to work differently. This is all very strange because the member is never used anywhere. I can comment that one line and the program recompiles just fine and works without error.
The whole program is ~ 3KLOC and it is very difficult to remove it.
I have absolutely no idea where to start looking. Any ideas?
Update
I found the problem: free
-ing malloc
-ed memory and delete
-ing new
-ed memory are unsafe in the same program.
source to share
Off the top of my head, without seeing any code (see comments on your question), I would suggest a rogue pointer that usually stomps on something you don't notice, but the introduction of a new member makes it stomp on what you are doing notice ...
Try adding members of different sizes or more (unused) int
members, or maybe a line in the form: const char xxx[50];
to reserve more space.
source to share
99 times out of 100 I find that if you change the data structure of the class and start getting weird crashes then the assembly dependencies are not quite correct i.e. you need to rebuild something that for some reason is not recoverable.
If it's not a big pain to completely clean up and rebuild your entire project, then I would give this and then we can work this answer out.
source to share
A little more information about the crash would be helpful, since there are multiple ways a program can crash. However, the first thing I do on Linux if I suspect it might be a memory error is to run the program through Valgrind (Memcheck) and see what it can tell me.
Also like a shot in the dark, does your build system build dependencies correctly? One possibility is that you are modifying the abstract class, but not recompiling all the source files that depend on the abstract class, which can be problematic.
source to share