Jump to content
  • Advertisement
Sign in to follow this  
Ripiz

[C++] Weird error

This topic is 3122 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!