Hi Everyone,
Coverity alerted to about 85 memory leaks under Windows. Ominously, it
coincided with the 80 or so objects dumped after running a Debug build
under Visual Studio.
I've got it tracked down to this pattern. It appears MSC compilers a not
generating the call to a destructor:
// Header file
static const & Integer& Integer::Zero();
// Source file
static const & Integer& Integer::Zero()
{
return Singleton<Integer>().Ref();
}
There's a reason for the singleton and where its placed. It has to do with
(1) C++ guarantees on static object initialization, modulo (2) thread local
storage on some Windows platforms.
A quick experiment cutting Zero(), One() and Two() over tow the following
removed about 40 of the reported leaks. It also cleared the Coverity
warnings. The header stayed the same:
// Source file
static const Integer& s_zero = Singleton<Integer>().Ref();
static const Integer& Integer::Zero()
{
return s_zero;
}
I'm not sure what to make of it. The "return Singleton<Integer>().Ref()" is
just an anonymous object and its supposed to work. Other platforms don't
have the problem.
Below is an audit for the pattern. The source files (*.cpp) should be easy
to modify. The header files (*.h) could be trickier because we can't use a
function scope static local due to the problem with Windows and thread
local storage.
My questions are:
* is this a problem that we need to address?
* if so, then how do we address it?
My third question s:
* would someone with MSDN or Microsoft Connect access please report the
bug to Microsoft?
Jeff
********************
riemann:cryptopp$ grep -IR Singleton * | grep return
dh.h: {return Singleton<DH_Algorithm>().Ref();}
ec2n.cpp: return Singleton<Point>().Ref();
ecp.cpp: return Singleton<Point>().Ref();
gf2n.cpp: return Singleton<PolynomialMod2>().Ref();
gf2n.cpp: return Singleton<PolynomialMod2, NewPolynomialMod2<1>
>().Ref();
polynomi.cpp: return Singleton<ThisType>().Ref();
polynomi.cpp: return Singleton<ThisType, NewOnePolynomial>().Ref();
pubkey.h: {return Singleton<CPP_TYPENAME
SCHEME_OPTIONS::MessageEncodingMethod>().Ref();}
pubkey.h: {return Singleton<CPP_TYPENAME
SCHEME_OPTIONS::SignatureAlgorithm>().Ref();}
pubkey.h: {return Singleton<CPP_TYPENAME
SCHEME_OPTIONS::KeyAgreementAlgorithm>().Ref();}
pubkey.h: {return Singleton<CPP_TYPENAME
SCHEME_OPTIONS::KeyDerivationAlgorithm>().Ref();}
pubkey.h: {return Singleton<CPP_TYPENAME
SCHEME_OPTIONS::SymmetricEncryptionAlgorithm>().Ref();}
pubkey.h: {return Singleton<CPP_TYPENAME
SCHEME_OPTIONS::MessageEncodingMethod>().Ref();}
xtr.cpp: return Singleton<GFP2Element>().Ref();
zinflate.cpp: return m_blockType == 1 ? Singleton<HuffmanDecoder,
NewFixedLiteralDecoder>().Ref() : m_dynamicLiteralDecoder;
zinflate.cpp: return m_blockType == 1 ? Singleton<HuffmanDecoder,
NewFixedDistanceDecoder>().Ref() : m_dynamicDistanceDecoder;
riemann:cryptopp$
--
--
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.
---
You received this message because you are subscribed to the Google Groups
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.