Sign in to follow this  

No idea what this means...[Boost/Raknet]

This topic is 3634 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 writing an online game using Raknet. But after a few loops around the game loop I get this weird asset error and I have no idea what is causing it. Debug Assertion Failed File: dbgdel.cpp Line: 52 Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) This is where the error occurs, it stops when I comment this section out

			boost::shared_ptr<Packet> packet ( m_networkManager->getPackets() );

			if( packet.get() )
			{
				switch( packet->data[0] )
				{
				case ID_REMOTE_DISCONNECTION_NOTIFICATION:
					// Client disconnected
					logger.write( "Client disconnected" );	
					break;

				case ID_CONNECTION_REQUEST_ACCEPTED:
					logger.write( "We have connected" );
					break;
				
				case ID_NO_FREE_INCOMING_CONNECTIONS:
					logger.write( "Server is full" );
					break;

				case ID_REMOTE_CONNECTION_LOST:
					// Client lost connection
					logger.write( "Client lost connection" );
					break;

				case ID_REMOTE_NEW_INCOMING_CONNECTION:
					// New client connected
					logger.write( "Client Connected" );
					break;

				default:
					// Unhandled Packet
					logger.write( boost::format( "Unhandled Packet" ) );
					break;
				}
				m_networkManager->deletePacket( packet );
				
			}

The network manager...
	NetworkManager::NetworkManager()
	{
		logger.write( "Initializing the network manager..." );
		boost::shared_ptr<RakPeerInterface> peer( RakNetworkFactory::GetRakPeerInterface() );
		m_peer = peer;
	}

	NetworkManager::~NetworkManager()
	{
		
	}

	bool NetworkManager::startConnection( const std::string& ip, int port )
	{
		m_peer->Startup( 1, 30, &SocketDescriptor(), 1 );
		m_peer->Connect( ip.c_str(), port, 0, 0 );
		
		if( m_peer->IsActive() )
			logger.write( "Connected to server" );
		return true;
	}

	void NetworkManager::endConnection()
	{
		RakNetworkFactory::DestroyRakPeerInterface( m_peer.get() );
	}

	boost::shared_ptr<Packet> NetworkManager::getPackets()
	{
		boost::shared_ptr<Packet> packet( m_peer->Receive() );

		return packet;
	}

	void NetworkManager::deletePacket( boost::shared_ptr<Packet> packet )
	{
		m_peer->DeallocatePacket( packet.get() );
	}



Share this post


Link to post
Share on other sites
It means you clobbered memory (buffer overrun), or maybe you tried to double-delete something. The code posted is of no use in solving the problem I'm afraid.

Share this post


Link to post
Share on other sites
Ok...I just commented out that selection in the game loop to see what happens again. Now I get an error after the return of main()...a problem with boost deleting a pointer. What is the best way to track this down?

Share this post


Link to post
Share on other sites
I'm not familiar with RakNet, but I'm curious about this:
...RakNetworkFactory::GetRakPeerInterface()...
I gather this returns a pointer, but who owns it?

I ask because with some similar APIs (such as SDL), you sometimes acquire pointers to things that you do not in fact own. If that's the case here, then storing the retrieved pointer in a boost::shared_ptr object will probably not end well. (I can't say for sure that that's what's going wrong, but it might at least be worth looking into...)

Share this post


Link to post
Share on other sites
Quote:
Original post by Stormtrooper
Ok, I removed the smart pointers from the Raknet stuff, and everything works now. Thanks for the help.


I hope you didn't just do that blindly! Even though delete-ion is potentially bad with this API, it doesn't exclude the possibility that there exists a clean-up function that needs to be called. You could be leaking resources.

Did you check?

Share this post


Link to post
Share on other sites
Did you check out the possibility that this:
boost::shared_ptr<Packet> packet ( m_networkManager->getPackets() );
could be trying to construct a NULL shared_ptr?


Nevermind. This shouldn't matter.

[Edited by - Maxamor on January 6, 2008 6:34:56 PM]

Share this post


Link to post
Share on other sites

This topic is 3634 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.

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