0xC0000005: Access violation reading location 0xfeeefeee

279 views
Skip to first unread message

Alex Zhang

unread,
Apr 18, 2010, 2:55:41 PM4/18/10
to Crypto++ Users
Hello all,

I wrote a program using crypto++ and vc 2008 and got a error when
running my program like this:

Unhandled exception at 0x00d8f90a in NeuroNetworkAssemble.exe:
0xC0000005: Access violation reading location 0xfeeefeee.

The program is a two-thread communication program goes like the server
using Elgamal to generate a private key and a publickey, and send the
public key to the client, client uses that key to do some encryption
and then closes the client thread, then the server using the key to do
some encryption and decryption and then closes its thread.

Program crashes when the server thread is over.
I check the stack window, it points to a destruct function. According
to my guess, it seems like when the client thread ends, the system
would destruct all secure object like keys, integers in the memory. So
when the server thread ends, system will try to destruct those for
another time, therefore the exception occurs.

Could anyone give me some idea about this issue? If my guess is right,
how can i fix this? Thanks.

I call the stack window and locate the error, it shows that :
> NeuroNetworkAssemble.exe!std::_Destroy<CryptoPP::Integer>(CryptoPP::Integer * _Ptr=0x00256c68) Line 59 + 0xc bytes C++
NeuroNetworkAssemble.exe!
std::allocator<CryptoPP::Integer>::destroy(CryptoPP::Integer *
_Ptr=0x00256c68) Line 160 + 0x9 bytes C++
NeuroNetworkAssemble.exe!
std::_Destroy_range<std::allocator<CryptoPP::Integer>
>(CryptoPP::Integer * _First=0x00256c68, CryptoPP::Integer *
_Last=0x00256c7c, std::allocator<CryptoPP::Integer> & _Al={...},
std::_Nonscalar_ptr_iterator_tag __formal={...}) Line 234 + 0xc bytes
C++
NeuroNetworkAssemble.exe!
std::_Destroy_range<std::allocator<CryptoPP::Integer>
>(CryptoPP::Integer * _First=0x00256c68, CryptoPP::Integer *
_Last=0x00256c7c, std::allocator<CryptoPP::Integer> & _Al={...}) Line
225 + 0x2f bytes C++
NeuroNetworkAssemble.exe!
std::vector<CryptoPP::Integer,std::allocator<CryptoPP::Integer>
>::_Destroy(CryptoPP::Integer * _First=0x00256c68, CryptoPP::Integer *
_Last=0x00256c7c) Line 1124 + 0x14 bytes C++
NeuroNetworkAssemble.exe!
std::vector<CryptoPP::Integer,std::allocator<CryptoPP::Integer>
>::_Tidy() Line 1137 C++
NeuroNetworkAssemble.exe!
std::vector<CryptoPP::Integer,std::allocator<CryptoPP::Integer>
>::~vector<CryptoPP::Integer,std::allocator<CryptoPP::Integer> >()
Line 560 C++
NeuroNetworkAssemble.exe!
CryptoPP::DL_FixedBasePrecomputationImpl<CryptoPP::Integer>::~DL_FixedBasePrecomputationImpl<CryptoPP::Integer>()
+ 0x54 bytes C++
NeuroNetworkAssemble.exe!
CryptoPP::DL_PublicKeyImpl<CryptoPP::DL_GroupParameters_GFP_DefaultSafePrime>::~DL_PublicKeyImpl<CryptoPP::DL_GroupParameters_GFP_DefaultSafePrime>()
+ 0x57 bytes C++
NeuroNetworkAssemble.exe!
CryptoPP::DL_PublicKey_GFP<CryptoPP::DL_GroupParameters_GFP_DefaultSafePrime>::~DL_PublicKey_GFP<CryptoPP::DL_GroupParameters_GFP_DefaultSafePrime>()
+ 0x2b bytes C++

--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-user...@googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.

Subscription settings: http://groups.google.com/group/cryptopp-users/subscribe?hl=en

Alex Zhang

unread,
Apr 27, 2010, 5:25:24 AM4/27/10
to Crypto++ Users
My problem still stands there.

I was wondering if my way to pass the the public key is wrong.
Here's how I pass the public key from a server thread to a client
thread:

First, in the server thread, I use the following code to generate a
private key and public key
RandomPool rngA;
ElGamalDecryptor elGamalPrivateKey(rngA,8*PRIVATE_KEY_LENGTH);
ElGamalEncryptor elGamalPublicKey(elGamalPrivateKey);
And then, I use socket to send the elGamalPublicKey object to the
client's side. But before I send it to the client, I create a public
key "holder" by calling the same codes as the server side.
RandomPool rngA;
ElGamalDecryptor elGamalPrivateKey1(rngA,
8*PRIVATE_KEY_LENGTH);
ElGamalEncryptor elGamalPublicKey1(elGamalPrivateKey);
After that, I use memcpy() to overwrite the elGamalPublicKey1 with the
content received from the socket. Therefore the client side gets a
exactly same public key with the server.

The Encryption and Decryption is correct. But when a thread ends after
another, it will cause a Exception, saying Access Violation.
According to the stack window, it seems the system will try to destroy
some key material for twice. Therefore, no matter which thread ends
first, the one which ends after that will generate a exception.

Could anyone give me some suggestion or help? Thanks a lot.
> More information about Crypto++ and this group is available athttp://www.cryptopp.com.
Reply all
Reply to author
Forward
0 new messages