crypto++ strangely crashes

62 views
Skip to first unread message

Anton Dvorkin

unread,
Apr 13, 2012, 8:19:29 AM4/13/12
to Crypto++ Users
Hi!

I need to use cryptography in my project (visual c++ 2008 sp1, exe
with several dlls, uses some third party libs; crypto++ 5.6.1, Windows
7). I chose crypto++. I use it as static library. First, I tested all
functions I need in test console application, and everything works
fine.

Then I started to integrate this function to the project.

And it crashes on many of cryptopp function calls, including very
simple like this one:
CryptoPP::FileSource file("publicKeySign.der", true);

During the call of this line of code, application crashes with:

Unhandled exception at 0x00c56619 in Starter.exe: 0xC0000005: Access
violation reading location 0x00006f70.

Here is my call stack:
Starter.exe!
CryptoPP::member_ptr<CryptoPP::AlgorithmParametersBase>::reset(CryptoPP::AlgorithmParametersBase
* p=0x00000000) Line 50 + 0x9 bytes C++
Starter.exe!CryptoPP::AlgorithmParameters::operator()<char const
*>(const char * name=0x00d8ec04, const char * const &
value=0x00d88a44, bool throwIfNotUsed=true) Line 356 C++
Starter.exe!CryptoPP::MakeParameters<char const *>(const char *
name=0x00d8ec04, const char * const & value=0x00d88a44, bool
throwIfNotUsed=true) Line 388 + 0x2d bytes C++
Starter.exe!CryptoPP::FileSource::FileSource(const char *
filename=0x00d88a44, bool pumpAll=true,
CryptoPP::BufferedTransformation * attachment=0x00000000, bool
binary=true) Line 65 + 0x6d bytes C++
Starter.exe!PDD::PDDApp2::Open() Line 237 C++
Starter.exe!WinMain(HINSTANCE__ * __formal=0x00c50000, HINSTANCE__ *
__formal=0x00c50000, HINSTANCE__ * __formal=0x00c50000, HINSTANCE__ *
__formal=0x00c50000) Line 387 + 0xb bytes C++
Starter.exe!__tmainCRTStartup() Line 578 + 0x1d bytes C
kernel32.dll!@BaseThreadInitThunk@12() + 0x12 bytes
ntdll.dll!___RtlUserThreadStart@8() + 0x27 bytes
ntdll.dll!__RtlUserThreadStart@8() + 0x1b bytes

Both my project and crypto++ use Multi-threaded DLL runtime libraries.

I tried to change crypto++ project options for them to be the same as
my project options, but it doesn't help (after some changes
application crashes with another call stack).

Any ideas will be appreciated!

Thanks!

Anton

Anton Dvorkin

unread,
Apr 16, 2012, 4:09:36 AM4/16/12
to Crypto++ Users
Today I tried to add crypto++ source files directly to my project. And
got the same result - application crashes even on simple operations.
For examlpe:

int APIENTRY WinMain(HINSTANCE /*hInstance*/, HINSTANCE /
*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/)
{
CryptoPP::StringSource strCr("abc", true /*pumpAll*/);

//...
}



Call stack:


> msvcr90.dll!memcpy(unsigned char * dst=0x0028f993, unsigned char * src=0x00000301, unsigned long count=1) Line 348 Asm
Starter.exe!CryptoPP::ArraySink::Put2(const unsigned char *
begin=0x00000301, unsigned int length=1, int messageEnd=0, bool
blocking=true) Line 513 + 0x42 bytes C++
Starter.exe!CryptoPP::BufferedTransformation::ChannelPut2(const
std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
channel="", const unsigned char * begin=0x00000301, unsigned int
length=1, int messageEnd=0, bool blocking=true) Line 357 + 0x1e bytes
C++
Starter.exe!
CryptoPP::StringStore::CopyRangeTo2(CryptoPP::BufferedTransformation &
target={...}, unsigned __int64 & begin=0, unsigned __int64 end=1,
const
std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
channel="", bool blocking=true) Line 1069 + 0x29 bytes C++
Starter.exe!
CryptoPP::BufferedTransformation::CopyRangeTo(CryptoPP::BufferedTransformation
& target={...}, unsigned __int64 position=0, unsigned __int64
copyMax=1, const
std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
channel="") Line 912 + 0x41 bytes C++
Starter.exe!
CryptoPP::BufferedTransformation::CopyTo(CryptoPP::BufferedTransformation
& target={...}, unsigned __int64 copyMax=1, const
std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
channel="") Line 908 + 0x23 bytes C++
Starter.exe!CryptoPP::BufferedTransformation::Peek(unsigned char *
outString=0x0028f993, unsigned int peekMax=1) Line 439 + 0x18 bytes C+
+
Starter.exe!CryptoPP::BufferedTransformation::Peek(unsigned char &
outByte=0) Line 430 C++
Starter.exe!CryptoPP::BufferedTransformation::AnyRetrievable() Line
401 + 0x11 bytes C++
Starter.exe!
CryptoPP::BufferedTransformation::TransferMessagesTo2(CryptoPP::BufferedTransformation
& target={...}, unsigned int & messageCount=0, const
std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
channel="", bool blocking=true) Line 506 + 0xd bytes C++
Starter.exe!
CryptoPP::BufferedTransformation::TransferAllTo2(CryptoPP::BufferedTransformation
& target={...}, const
std::basic_string<char,std::char_traits<char>,std::allocator<char> > &
channel="", bool blocking=true) Line 555 + 0x19 bytes C++
Starter.exe!
CryptoPP::SourceTemplate<CryptoPP::StringStore>::PumpAll2(bool
blocking=true) Line 767 + 0x2d bytes C++
Starter.exe!CryptoPP::Source::PumpAll() Line 738 + 0x19 bytes C++
Starter.exe!CryptoPP::Source::SourceInitialize(bool pumpAll=true,
const CryptoPP::NameValuePairs & parameters={...}) Line 750 C++
Starter.exe!CryptoPP::StringSource::StringSource(const char *
string=0x01202dc0, bool pumpAll=true, CryptoPP::BufferedTransformation
* attachment=0x00000000) Line 786 + 0x9e bytes C++
Starter.exe!WinMain(HINSTANCE__ * __formal=0x00f20000, HINSTANCE__ *
__formal=0x00f20000, HINSTANCE__ * __formal=0x00f20000, HINSTANCE__ *
__formal=0x00f20000) Line 104 + 0x14 bytes C++
Starter.exe!__tmainCRTStartup() Line 578 + 0x1d bytes C
kernel32.dll!@BaseThreadInitThunk@12() + 0x12 bytes
ntdll.dll!___RtlUserThreadStart@8() + 0x27 bytes
ntdll.dll!__RtlUserThreadStart@8() + 0x1b bytes



I can't understand the reason of this strange behaviour.



Anton

Reply all
Reply to author
Forward
0 new messages