> Just have seen another way of the problem occurrence. simple_ptr is
> double constructed, and m_p = m_objectFactory happens after the last
> construction (so no AV), however double construction means double
> atexit destructor registration and simple_ptr pointed object is double
> deleted on exit.
I wonder if it is possible to hack around by forcing singleton
initialization at CRT startup this way:
template <class T, class F = NewObject<T>, int instance=0>
class Singleton
{
...
private:
static const T* init;
};
template<class T, class F, int instance>
const T* Singleton<T, F, instance>::init = Singleton<T, F,
instance>::Ref();
CryptoPP already has some static data, and thus relies on CRT
initialization and that is guaranteed to happen singlethreadedly
(right?).
There will be one copy of init in each compilation unit, but linker
will select only one.
This will cause static init fiasco in case object's factory relies on
any global static data, and might need special care for dynamic
linking, but otherwise should guarantee singleton being always
properly initialized in main thread. (Unless you spawn threads in
constructors of you statics, then you totally deserve whatever
happens :)).
Or am I missing something?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---