I'm currently writing a C++ program and I've come across some weird segmentation fault. With luck I found out that some variable of some class of mine suddenly changes into some weird values that I've never assigned to that specific variable. However, when trying to debug my progam with gdb, it seems impossible to find out why the variable is 'changed', although it seems more like some sort of access violation occurs. I've tried to use the tools valgrind and electric fence to find any such errors, but the only errors I find are those that eventually occur because the values of my variables seem to be assigned random values before that for some unknown reason. It also seems that
Firstly, what are the semantics of chi::SPtr? It would appear to be some kind of smart pointer class. Is it unique ownership or shared ownership?
Secondly, FormatStatement containing a pointer to an instance of a base class raises a red flag for me. Does your object graph contain any cycles? I don't know of any smart pointer implementations that are able to reclaim object graphs with cycles.
An example of an object graph with cycles is a directory tree structure where a folder points to the files it contains and a file points to the folder that contains it.