Sign in to follow this  
Ripiz

[C++] Weird error

Recommended Posts

Ripiz    539
I'm using Visual Studio 2010 Ultimate. DirectX 9 SDK, also RakNet networking library. But I think these aren't related to the problem. Debugger throws this error:
Unhandled exception at 0x5d59ad4a (msvcp100d.dll) in Server.exe: 0xC0000005: Access violation reading location 0x003493c4.
Error is showed in xutility file, if I track back, calls go through string header, then into my code:
void RPCLogin(RPCParameters *RPC){
	if(GetIndex(RPC->sender.binaryAddress)>=0) return;
	BitStream b(RPC->input, BITS_TO_BYTES(RPC->numberOfBitsOfData), false);
	string acc,pass,file;
	b.ReadCompressed(acc); //if I comment this line, it's all fine
} //shows on this bracket (deconstructor?)
Any ideas what wrong? Or maybe some information missing? Thank you in advance. Edit: If I build in release mode, not debug, there's no error and everything works fine.

Share this post


Link to post
Share on other sites
Evil Steve    2017
Looks like ReadCompressed() is causing you to read past the end of an array, or reading an invalid pointer in your BitStream class.

Share this post


Link to post
Share on other sites
Ripiz    539
I tried debugging, 'acc' string was right, without any artificials. However if I set value manually, not read from BitStream, there's no error. Any way to identify what's the problem exactly?

Share this post


Link to post
Share on other sites
Aardvajk    13207
I know nothing about RakNet's BitStream, but from looking at the docs...

Quote:
From RakNet docs
template<class templateType> bool RakNet::BitStream::ReadCompressed(templateType &var)
Read any integral type from a bitstream.


...I would seriously question whether it is possible to pass something like a std::string to the function. I'd suspect the function internally does something like write_to(&t,sizeof(T),data) which simply won't work for a non-POD type.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this