Jump to content

Client Debug - Assertion Failed !


Recommended Posts

1 hour ago, WeedHex said:

lzo.cpp

line 29

(capacity >0)

Assertion failure

 

?

 


        assert(capacity > 0);

 

 

This is the file and line ;

 

#include "StdAfx.h"
#include <stdlib.h>
#include <lzo/lzoLibLink.h>

#include "lzo.h"
#include "tea.h"
#include "debug.h"

#define dbg_printf

static class LZOFreeMemoryMgr
{
public:
	enum
	{
		REUSING_CAPACITY = 64*1024,
	};
public:
	~LZOFreeMemoryMgr()
	{
		for(size_t i = 0; i < m_freeVector.size(); ++i)
		{
			delete m_freeVector[i];
		}
		m_freeVector.clear();
	}
	BYTE* Alloc(unsigned capacity)
	{
		assert(capacity > 0);
		if (capacity < REUSING_CAPACITY)
		{
			if (!m_freeVector.empty())
			{
				BYTE* freeMem = m_freeVector.back();
				m_freeVector.pop_back();

				dbg_printf("lzo.reuse_alloc\t%p(%d) free\n", freeMem, capacity);
				return freeMem;
			}
			BYTE* newMem = new BYTE[REUSING_CAPACITY];
			dbg_printf("lzo.reuse_alloc\t%p(%d) real\n", newMem, capacity);
			return newMem;
		}
		BYTE* newMem = new BYTE[capacity];
		dbg_printf("lzo.real_alloc\t%p(%d)\n", newMem, capacity);
		return newMem;
	}

 

What should i do now ? Thanks.

Link to comment
Share on other sites

you can backtrace the function calls in Visual Studio. Do this and you'll see what exactly causes the crash to happen.

The reason is: Alloc() should NOT be used with a capacity of 0. Why, you may ask?

That can be explained by two reasons: First, Alloc() is there to allocate some memory if there's not enough memory left in m_freeVector (which allocates

64*1024 bytes as stated above in the file).

So, naturally you'd think about this: HOW MUCH memory needs to be allocated? And here you got your answer to the question above. Your function gets a call with capacity == 0. This means that 0 memory is needed and 0 bytes of memory should be allocated. Does that make any sense? Nope! We have an abnormal situation here and the program needs to be terminated since something went seriously wrong.

Needless to say, removing that alloc line will NOT fix your problem.

 

So, how could this happen? Since we're talking about lzo maybe one of your packs has 0 size or is otherwise corrupt? I'd advise you to backtrace the function calls so you may find out what operation exactly triggers Alloc(0) and therefore causes the crash. This should solve your problem then.

  • Love 2

We are the tortured.
We're not your friends.
As long as we're not visible.
We are unfixable.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.