I am trying to find the root cause of an COleException being thrown by my service in production environment. I have checked the crash dump file, and the exception is thrown when trying to construct a string.
COleException is thrown inside void SetLength(_In_ int nLength):
void SetLength(_In_ int nLength)
{
ATLASSERT( nLength >= 0 );
ATLASSERT( nLength <= GetData()->nAllocLength );
if( nLength < 0 || nLength > GetData()->nAllocLength)
AtlThrow(E_INVALIDARG); // EXCEPTION THROWN HERE BECAUSE GetData()->nAllocLength IS 0 WHILE nLength IS 38
GetData()->nDataLength = nLength;
m_pszData[nLength] = 0;
}
Since this is deep inside Microsoft's code (atlsimpstr.h) I'm not certain what is happening. Just wondering if anyone has experienced CString behaving like this?
Call stack:
ATL::CSimpleString::SetLength()ATL::CSimpleString::ReleaseBufferSelLength()ATL::CString::FormatV()ATL::CString::Format()ActiveSocket->ErrorText.Format("Socket %d failed during read?. Error %s", ActiveSocket->Handle, (LPCSTR)Socket::SockErrorAsPrintable(ActiveSocket->Handle));
ActiveSocket->ErrorText is of type CString.
I am using Windows SDK 10.0, v142 Platform Toolset and C++ Language Standard is set to ISO C++14 Standard.