AsyncQueue queue overflow & DataBuffer MAV

Monkey Forums/Monkey Bug Reports/AsyncQueue queue overflow & DataBuffer MAV

k.o.g.(Posted 2015) [#1]
Hello mark

I got 2 new errors....
First, i'm writting an Websocket Server with pure brl.socket module, at the same time, i write also an module for Websocket Client with brl.socket.

When i run an GLFW Application with brl.socket, i got random times an DataBuffer MAV Error:


and on the Serverside, i got once time this error:
Monkey Runtime Error : AsyncQueue queue overflow!
D:/MonkeyXPro82b/modules/brl/socket.monkey<80>
D:/MonkeyXPro82b/modules/brl/socket.monkey<449>
D:/MonkeyXPro82b/modules/kog/network/server.monkey<364>
D:/MonkeyXPro82b/modules/kog/network/server.monkey<207>
D:/MonkeyXPro82b/modules/kog/network/demoserver.monkey<99>
D:/MonkeyXPro82b/modules/kog/network/demoserver.monkey<52>


have you any idea, what happens?

i can't get any got, because its simple socket Application with Async Operations...
the DataBuffer error is on this line:
If Not _New( length ) Error "Allocate DataBuffer failed"

but the Error got never fired..



*update*
i changed the _New code:
bool  BBDataBuffer::_New( int length, void *data )
{
	if ( _data ) return false;
	if ( !data ) data = malloc( length );
	if ( !data) return false;  // HERE, check for null pointer...
	_data = (signed char *)data;
	_length = length;
	return true;
}

now i become a throw error "Allocate DataBuffer failed" sometimes


*update 2*
i'm not a pro in C++, but now it seems to work:
#define MAXALLOCCOUNT 20
static unsigned char mallocCount;
void *safeAlloc(size_t size)
{
	if (size <= 0 ) return NULL;

	//C Style
	//void *ptr = malloc(size);

	//C++ Style
	void *ptr = NULL;
	try
	{
		ptr = new char *[size];
	}
	catch (...) {}

	if (ptr == NULL)
	{
		/*
		** Loop safety
		*/
		mallocCount++;
		if (mallocCount >= MAXALLOCCOUNT) return NULL;

		return safeAlloc(size);
	}
	else
	{
		memset(ptr, 0, size);
		return ptr;
	}
}

until now, i dont have any more errors with the databuffer


marksibly(Posted 2015) [#2]
> Monkey Runtime Error : AsyncQueue queue overflow!

This means you are performing too many async sends to a peer, without that peer having recved any data.

Ideally, you should only be performing one async send at a time - ie: perform op; wait for server response; perform next op etc. However, Monkey does let you buffer up to 256 ops, allowing you to send, send, send, recv etc, for up to 256 sends. It could be that your app architecture is a bit flawed if it's just blinding 'sending' without syncing with server in any way.

If malloc is failing, your app must be consuming vast amounts of memory (>2gb?)! How big are the buffers you're using? Could it be related to the send issue above?


k.o.g.(Posted 2015) [#3]
Hi mark

The buffers are not big, so 20 bytes.. But many times in a minute..
Taskmanager says, the app used only 20mb RAM.
I changed the code from above and now, it runs without crash..
You have also forgott to check, if malloc was successful:)

I think, the overflow problem is not anymore an problem.
But the crash was only on a windows OS.