This is a weird problem and I'm not sure what to make of it.
I have something like the following:
struct Parms
{
    const std::string value1;
    const std::string value2;
    std::string parm1;
    std::string parm2;
    Parms() : parm1(value1), parm2(value1) {}
    static const Parms& getDefaults()
    {
        static Parms defaults;
        return defaults;
    }
};
Which I generally use like so:
Parms myParms = Parms::getDefaults();
myParms.parm1 = "crap";
functionThatNeedsParms(myParms);
Pretty straightforward. This has never caused me any headaches, until I started trying to write unit tests that use this code, using CxxTest. I have two test suite classes in different files, and when I run them individually, everything is great.
When I run them together, I see two bad things. First, the whole thing core dumps trying to double free the static defaults variable. Secondly, if I look at the contents of defaults some time before it dies, but after I've started using it, the static const std::strings that are in there are corrupted (some letters have randomly changed, though it is always the same on every run).
What is going on?
 
     
     
    