Skip to main content
GameDev.net gamedev.net
🔒 Locked

stl vector memory problem

Started by assainator Jul 25, 2010 at 8:09 AM 23 replies 10.4k views
Original Post
assainator
assainator
Hello all,

I'm creating a custom stack class. I'm using the stl vector as a base.
But I'm having problems with popping a value of the stack.
If can push as much values onto the stack as I want. But if I pop more then 1 off, the program will give the following message
Quote:
Unhandled exception at 0x702151a3 (Ice.dll) in TestApp.exe: 0xC0000005: Access violation reading location 0x00000006.


I can't find the problem. All the values I push onto the stack are valid.

the call stack


The source code

IceStack.hpp
#pragma once//custom includes#include "EasX_Api.hpp"#include "Value.hpp"//standard includes#include <stack>using namespace std;class IceStack{	public:		EASX_API IceStack(void);		EASX_API ~IceStack(void);		EASX_API void Push(Value v);		EASX_API Value Pop(); //this is the problem function, see 		EASX_API unsigned int GetSize();		EASX_API Value *Peek(unsigned int index);	private:		std::vector<Value> _stack;};


IceStack.cpp
#include "IceStack.hpp"IceStack::IceStack(void){}IceStack::~IceStack(void){}void IceStack::Push(Value v){	//push the value on the stack	_stack.push_back(v);}Value IceStack::Pop(){	//if the stack is not empty, pop a value of the stack and return it	if(!_stack.empty())	{		Value v= _stack.back();		_stack.pop_back();		return v;	}	//if the stack is empty, return a empty value	else	{		return Value();	}}unsigned int IceStack::GetSize(){	//return the size	return _stack.size();}Value *IceStack::Peek(unsigned int index){	//return a pointer to the value	return &_stack[index];}
"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me

SiCrane
SiCrane
It looks like you're calling a member function on a null pointer. Double check the entire call stack to make sure that all your pointers are valid.
serratemplar
serratemplar
Can you post the code where you actually instantiate one of these objects and work with it?
assainator
assainator
The strange thing is this, if I run the example below, it works fine. But in the way the stack is supposed to be used (see underneath the example) it gives the error I posted before.


example that runs fine:
//create a stackIceStack *is = new IceStack();//create two valuesValue val1(Type::Int, (int)55);Value val2(Type::Float, (float)1234.567);//create two empty valuesValue val3;Value val4;//push the first two valuesis->Push(val1);is->Push(val2);//pop the values of the stackval3 = is->Pop();  //val3 = val2val4 = is->Pop();  //val4 = val1  -- I expected the same error here


The stack I'm making is used in a script virtual machine. If the stack is used from within the script then there are no errors at all (fortunately).

But the error does occur in the code below.
It is a function that is used to make extensions for the virtual machine. As you can see, the function is provided with a pointer to the stack. The function pops as many values of the stack as it needs. But the second time the function pops a value of the stack, I get the error described in the above post.
But the provided stack is valid and I can't find anything else that could cause the problem.

I hope that any of you can give some advice.

//the function for use in extending
int IceExtension::ParseStack(const char *format, IceStack *Stack, ...){	va_list ap;	va_start(ap, format);	for(unsigned int i = 0; i < strlen(format); i++)	{		Value v;		v = Stack->Pop();		if(v._type == Type::Unkown)		{			return ICE_PARSE_STACK_FAILURE_CURRUPT_STACK;		}		if(format == 'i')		{			int *pInt = va_arg(ap, int*);			if(v._type == Type::Int)			{				memcpy(pInt, v._data, sizeof(int));			}			else if(v._type == Type::Float)			{				float tmp1;				memcpy(&tmp1, v._data, sizeof(float));				int tmp2 = tmp1;				memcpy(pInt, &tmp2, sizeof(int));			}			else			{				return ICE_PARSE_STACK_FAILURE_CURRUPT_STACK;			}		}		else if(format == 'f')		{			float *pFloat = va_arg(ap, float*);			if(v._type == Type::Float)			{				memcpy(pFloat, v._data, sizeof(float));			}			else if(v._type == Type::Int)			{				int tmp1;				memcpy(&tmp1, v._data, sizeof(int));				float tmp2 = tmp1;				memcpy(pFloat, &tmp2, sizeof(float));			}			else			{				return ICE_PARSE_STACK_FAILURE_CURRUPT_STACK;			}		}		else if(format == 't')		{			unsigned int *pUint = va_arg(ap, unsigned int *);			if(v._type == Type::TblIndex)			{				memcpy(pUint, v._data, sizeof(unsigned int));			}			else			{				return ICE_PARSE_STACK_FAILURE_CURRUPT_STACK;			}		}		else		{			return ICE_PARSE_STACK_FAILURE_WRONG_FORMAT;		}	}	va_end(ap);	return ICE_PARSE_STACK_SUCCES;}


I don't know if this is needed but here is the code for the 'Value' class

Value.hpp
#pragma once#include "EasX_Api.hpp"enum Type{	Unkown,		//This means error	Int,		//int	Float,		//float	MemIndex,	//unsigned int	TblIndex	//unsigned int};class Value{	public:		EASX_API Value(void);		EASX_API Value(Type t, int data);		EASX_API Value(Type t, float data);		EASX_API Value(Type t, unsigned int data);		EASX_API ~Value(void);		char *_data;		Type _type;};


Value.cpp
#include "Value.hpp"#include <stdlib.h>#include <string.h>#pragma warning(disable:4482)Value::Value(void){	_data = NULL;	_type = Type::Unkown;}Value::Value(Type t, int data){	_data = new char[sizeof(int)];	memcpy(_data, &data, sizeof(int));	_type = t;}Value::Value(Type t, float data){	_data = new char[sizeof(float)];	memcpy(_data, &data, sizeof(float));	_type = t;}Value::Value(Type t, unsigned int data){	_data = new char[sizeof(unsigned int)];	memcpy(_data, &data, sizeof(unsigned int));	_type = t;}Value::~Value(void){}
"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me

Enigma
Enigma
Your Value type is unsafe. It does not implement proper copy semantics and leaks memory. The constructors new[] memory but nothing delete[]s it and if you copy a value both the original and copy will point to the same memory, so changes to one will affect the other. This means it does not meet the requirements for value types in a std::vector. You need to give your Value type a copy constructor (which allocates memory and deep copies the value) and copy-assignment operator (which deletes and allocates memory and deep copies the value) and make the destructor delete[] the memory.

In the long term may I suggest you investigate some of the concepts presented here (this might be pretty heavy, so don't worry about digesting it all in one go, and feel free to ask questions):
#include <iostream>// C++ comes with a stack implementation#include <stack>// boost (www.boost.org) is a very useful set of libraries// I consider it a must-have for serious C++ coding#include <boost/utility.hpp>#include <boost/variant.hpp>// define your error codesint const ICE_PARSE_STACK_SUCCESS = 0;int const ICE_PARSE_STACK_FAILURE_CORRUPT_STACK = 1;int const ICE_PARSE_STACK_FAILURE_WRONG_FORMAT = 2;// create some types for your memory index and table indexstruct memory_index{	unsigned int value_;};struct table_index{	unsigned int value_;};// create a typedef to replace your value class// boost::variant is a datatype that holds exactly one of its listed types// at any time.  See http://www.boost.org/doc/libs/1_43_0/doc/html/variant.htmltypedef boost::variant< int, float, memory_index, table_index > value;// to access the value in a variant you apply a visitor// this visitor is for retrieving an int value from the visitorclass retrieve_int_stack_value	:	// we inherit from boost::static_visitor< int >	// so that boost's implementation knows that this	// visitor returns an int (our error code)	public boost::static_visitor< int >{	public:		// we'll store the value we extract from the stack		// into value, so we store a reference to it here		retrieve_int_stack_value(int & value)			:			value_(value)		{		}		// these functions are called by boost's implementation		// to retrieve a value from the variant.  In this case		// the variant stored an int and we want an int, so we		// simply perform an assignment		int operator()(int value) const		{			value_ = value;			return ICE_PARSE_STACK_SUCCESS;		}		// the variant contains a float and we want an int		int operator()(float value) const		{			value_ = static_cast< int >(value);			return ICE_PARSE_STACK_SUCCESS;		}		// the variant contains a memory_index and we want an		// int		int operator()(memory_index) const		{			return ICE_PARSE_STACK_FAILURE_CORRUPT_STACK;		}		// the variant contains a table_index and we want an		// int		int operator()(table_index) const		{			return ICE_PARSE_STACK_FAILURE_CORRUPT_STACK;		}	private:		int & value_;};// the version for retrieving a floatclass retrieve_float_stack_value	:	public boost::static_visitor< int >{	public:		retrieve_float_stack_value(float & value)			:			value_(value)		{		}		int operator()(int value) const		{			value_ = static_cast< float >(value);			return ICE_PARSE_STACK_SUCCESS;		}		int operator()(float value) const		{			value_ = value;			return ICE_PARSE_STACK_SUCCESS;		}		int operator()(memory_index) const		{			return ICE_PARSE_STACK_FAILURE_CORRUPT_STACK;		}		int operator()(table_index) const		{			return ICE_PARSE_STACK_FAILURE_CORRUPT_STACK;		}	private:		float & value_;};// the version for retrieving a memory_indexclass retrieve_memory_index_stack_value	:	public boost::static_visitor< int >{	public:		retrieve_memory_index_stack_value(memory_index & value)			:			value_(value)		{		}		int operator()(int) const		{			return ICE_PARSE_STACK_FAILURE_WRONG_FORMAT;		}		int operator()(float) const		{			return ICE_PARSE_STACK_FAILURE_WRONG_FORMAT;		}		int operator()(memory_index) const		{			return ICE_PARSE_STACK_FAILURE_WRONG_FORMAT;		}		int operator()(table_index) const		{			return ICE_PARSE_STACK_FAILURE_WRONG_FORMAT;		}	private:		memory_index & value_;};// the version for retrieving a table_indexclass retrieve_table_index_stack_value	:	public boost::static_visitor< int >{	public:		retrieve_table_index_stack_value(table_index & value)			:			value_(value)		{		}		int operator()(int) const		{			return ICE_PARSE_STACK_FAILURE_CORRUPT_STACK;		}		int operator()(float) const		{			return ICE_PARSE_STACK_FAILURE_CORRUPT_STACK;		}		int operator()(memory_index) const		{			return ICE_PARSE_STACK_FAILURE_CORRUPT_STACK;		}		int operator()(table_index value) const		{			value_ = value;			return ICE_PARSE_STACK_SUCCESS;		}	private:		table_index & value_;};// a common technique - depending on the type we want to read// we need to use different visitors, so define a bunch of overloaded// functions that return visitors of the appropriate typesretrieve_int_stack_value retrieve_stack_value(int & value){	return retrieve_int_stack_value(value);}retrieve_float_stack_value retrieve_stack_value(float & value){	return retrieve_float_stack_value(value);}retrieve_memory_index_stack_value retrieve_stack_value(memory_index & value){	return retrieve_memory_index_stack_value(value);}retrieve_table_index_stack_value retrieve_stack_value(table_index & value){	return retrieve_table_index_stack_value(value);}// a class for parsing a stack// we make this non-copyable to avoid accidently storing a copy of the// stack parser and parsing the same stack with multiple parsersclass stack_parser	:	boost::noncopyable{	public:		stack_parser(std::stack< value > & stack)			:			stack_(stack),			error_(ICE_PARSE_STACK_SUCCESS)		{		}		// a template member function which takes a reference to a		// type and, if the stack is not empty and no error has		// occured, retrieves the value from the top of the stack		// using boost::apply_visitor.  It returns a reference		// to itself so we can retrieve multiple values quickly and		// easily		template < typename type >		stack_parser & operator()(type & value)		{			if (!stack_.empty() && error_ == ICE_PARSE_STACK_SUCCESS)			{				error_ = boost::apply_visitor(retrieve_stack_value(value), stack_.top());				stack_.pop();			}			else if (error_ == ICE_PARSE_STACK_SUCCESS)			{				error_ = ICE_PARSE_STACK_FAILURE_CORRUPT_STACK;			}			return *this;		}		int error_code() const		{			return error_;		}	private:		std::stack< value > & stack_;		int error_;};int main(){	std::stack< value > stack;	stack.push(value(55));	stack.push(value(1234.567f));	int int_value;	float float_value;	// rather than using error-prone varargs we create a stack parser	// and retrieve values via successive applications of operator()	//int error_code = IceExtension::ParseStack("fi", stack, &float_value, ∫_value);	int error_code = stack_parser(stack)(float_value)(int_value).error_code();	std::cout << int_value << ' ' << float_value << '\n';}
assainator
assainator
Quote:
Original post by Enigma
Your Value type is unsafe. It does not implement proper copy semantics and leaks memory. The constructors new[] memory but nothing delete[]s it and if you copy a value both the original and copy will point to the same memory, so changes to one will affect the other. This means it does not meet the requirements for value types in a std::vector. You need to give your Value type a copy constructor (which allocates memory and deep copies the value) and copy-assignment operator (which deletes and allocates memory and deep copies the value) and make the destructor delete[] the memory.

In the long term may I suggest you investigate some of the concepts presented here (this might be pretty heavy, so don't worry about digesting it all in one go, and feel free to ask questions):
*** Source Snippet Removed ***


I have read the boost documentation about Boost.Variant. But I'm having a hard time understanding how it works and what your code does.
I understand what's hapening up the the line
typedef boost::variant< int, float, memory_index, table_index > value;

I'm having trouble understanding.
If I look at the class 'retrieve_int_stack_value' you show for getting a integer out the variant, I don't understand how it works. I don't see how you get the actual value from value variant

Could you please explain this to me?

assainator

"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me

Zakwayda
Zakwayda
Quote:
I have read the boost documentation about Boost.Variant. But I'm having a hard time understanding how it works and what your code does.
I understand what's hapening up the the line
typedef boost::variant< int, float, memory_index, table_index > value;

I'm having trouble understanding.
If I look at the class 'retrieve_int_stack_value' you show for getting a integer out the variant, I don't understand how it works. I don't see how you get the actual value from value variant
Check out the tutorial (it includes discussion of the various ways to retrieve the value of the variant, including the use of visitors).
Enigma
Enigma
To try and expand a bit on the tutorial, a visitor gets its value from the variant via the boost::apply_visitor function. boost::apply_visitor takes a visitor and a variant and internally calls the appropriate visitor function depending on the type currently held in the variant. To try and illustrate (note, this is not at all how the actual implementation works, I'm just trying to help you understand the usage):
#include <iostream>// A really rubbish int/float variantclass variant{	public:		variant(int value)			:			int_value_(value),			float_value_(0.0f),			is_int_(true)		{		}		variant(float value)			:			int_value_(0),			float_value_(value),			is_int_(false)		{		}		int int_value() const		{			return int_value_;		}		float float_value() const		{			return float_value_;		}		bool is_int() const		{			return is_int_;		}	private:		int int_value_;		float float_value_;		bool is_int_;};struct visitor{	// this is the function called by apply_visitor when the variant	// contains an int.  The parameter 'value' is the value of the	// variant	void operator()(int value) const	{		std::cout << "int " << value << '\n';	}	// this is the function called by apply_visitor when the variant	// contains a float.  The parameter 'value' is the value of the	// variant	void operator()(float value) const	{		std::cout << "float " << value << '\n';	}};void apply_visitor(visitor const & visitor_to_apply, variant & variant_to_visit){	// call the appropriate member function of visitor depending on	// the type in variant_to_visit (in a really rubbish way)	if (variant_to_visit.is_int())	{		visitor_to_apply(variant_to_visit.int_value());	}	else	{		visitor_to_apply(variant_to_visit.float_value());	}}int main(){	variant v1(3);	variant v2(7.0f);	apply_visitor(visitor(), v1);	apply_visitor(visitor(), v2);}

Obviously boost::variant is far more sophisticated in its implementation.

Σnigma
Zahlman
Zahlman
WTF is EasX_API?

And did you know the standard library provides a stack as well?

And what problem is this 'Value' type solving for you, exactly?
assainator
assainator
@Enigma: Thanks a lot, I think I understand it now!

@Zahlman:
1. __declspec(dllexport)
2. ever read the post of enigma?
3. ever read the post of enigma?

you're asking questions (2 & 3) that are already answered.

[Edited by - assainator on July 27, 2010 3:03:21 AM]
"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me

assainator
assainator
I have redone some of my code but I'm still having a issue like the first one.
I didn't go the boost way like enigma showed since I would need to rewrite almost all of my code.

What I have done since the first post:
I have removed the use of pointers to values in the Value class. I now use a union. This way there is no memory leak from the Value class and two Values classes can never point to the same value.

But the problem remains. Once I try to pop a second value of the stack I get another Access violation error.

I have tried to find the problem (check if a values was leaked after all (couldn't find), checked if the stack was trying to pop of a empty value (couldn't find)) but unfortunately I have not.

below is all the code I think is needed.

Thanks in advance,
assainator



some things need to know:
IceStack = std::vector<Value>IceStringTable = std::vector<char *>EASX_API = __declspec(dllexport) or __declspec(dllimport) (if a certain constant is declared in the msvc project, msvc will use the first


the code that goes wrong:
int IceExtension::ParseStack(const char *format, IceStack *Stack, IceStringTable *StrTable ...){	va_list ap;	va_start(ap, format);	for(unsigned int i = 0; i < strlen(format); i++)	{		//Pop a value		Value v = Stack->Pop();		switch(format[0])		{			case 'i':			{				if(v._type == Type::Int)				{					int *pInt = va_arg(ap, int*);					*pInt = v._data.Integer;				}				else if(v._type == Type::Float)				{					int *pInt = va_arg(ap, int*);					*pInt = v._data.Float;				}				else				{					return ICE_PARSE_STACK_FAILURE_CURRUPT_STACK;				}				break;			}			case 'f':			{				if(v._type == Type::Float)				{					float *pFlt = va_arg(ap, float*);					*pFlt = v._data.Float;				}				else if(v._type == Type::Int)				{					float *pFlt = va_arg(ap, float*);					*pFlt = v._data.Integer;				}				else				{					return ICE_PARSE_STACK_FAILURE_CURRUPT_STACK;				}				break;			}			case 's':			{				if(v._type == Type::TblIndex)				{					char **pStr = va_arg(ap, char**);					unsigned int index = v._data.Tbl;					char * data = (char*)malloc(strlen(StrTable->operator[](index))+1);					strcpy(data, StrTable->operator[](index));					*pStr = data;				}				break;			}		}	}	va_end(ap);	return ICE_PARSE_STACK_SUCCES;}


the new Value header & cpp file
#include "EasX_Api.hpp"enum Type{	Unkown,		//This means error	Int,		//int	Float,		//float	MemIndex,	//unsigned int	TblIndex	//unsigned int};union ValueData{	int Integer;	float Float;	unsigned int Mem;	unsigned int Tbl;};class Value{	public:		EASX_API Value(void);		EASX_API Value(Type t, int data);		EASX_API Value(Type t, float data);		EASX_API Value(Type t, unsigned int data);		EASX_API ~Value(void);		EASX_API static Value Copy(Value *v);		ValueData _data;		Type _type;};

#include "Value.hpp"#include <stdlib.h>#include <string.h>#pragma warning(disable:4244)#pragma warning(disable:4482)Value::Value(void){	_type = Type::Unkown;}Value::Value(Type t, int data){	_type = t;	_data.Integer = data;}Value::Value(Type t, float data){	_type = t;	_data.Float = data;}Value::Value(Type t, unsigned int data){	_type = t;	if(t == Type::MemIndex)	{		_data.Mem = data;	}	else if(t == Type::TblIndex)	{		_data.Tbl = data;	}}Value::~Value(void){}Value Value::Copy(Value *v){	Value val;	val._data = v->_data;	val._type = v->_type;	return val;}


a example that against my expectations runs fine:
	IceStack *is = new IceStack();	Value v1(Type::Int, (int)55);	Value v2(Type::Float, (float)1234.987);	is->Push(v1);	is->Push(v2);	Value v3 = is->Pop();	Value v4 = is->Pop(); //this is where I expected another access violation error	printf("v3._data.Float = %.3f", v3._data.Float);	printf("\nv4._data.Integer = %d", v4._data.Integer);


output from example:
v3._data.Float = 1234.987v4._data.Integer = 55
"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me

iMalc
iMalc
Quote:
Original post by Zahlman
And did you know the standard library provides a stack as well?
That's a particularly good question.
Considering that the following appears in his top source box you would think the answer would be yes:
#include <stack>
And yet somehow std::stack does not appear to be used here at all.
visitor
visitor
He seems to be including by mistake to get included.

He can't use std::stack, because it doesn't support the Peek functionality.
iMalc
iMalc
Quote:
Original post by visitor
He seems to be including by mistake to get included.

He can't use std::stack, because it doesn't support the Peek functionality.
I'm sure whatever he is writing would work just as well if it were written to use pop and push instead.

Quote:
for(unsigned int i = 0; i < strlen(format); i++)
Any chance you could just calculate the string length once rather than every time through that loop?!
assainator
assainator
I can indeed use the stl stack instead of a vector but I get the same error.
Quote:
Unhandled exception at 0x60bb5cd3 (Ice.dll) in TestApp.exe: 0xC0000005: Access violation reading location 0x00000006.


The idea behind the Peek functionality is to quickly access any number of values on any place in the stack. If I want to view the bottom Value class, I would have to pop all values of the stack storing them somewhere else, copy the value, and put everything back.

@iMalc: I can indeed do this but I haven't started making even the most basic optimizations since I first want to get everything working.



This is the IceStack if it uses std::stack
#pragma once#include "EasX_Api.hpp"#include "Value.hpp"#include <vector>#include <stack>using namespace std;class IceStack{	public:		EASX_API IceStack(void);		EASX_API ~IceStack(void);		EASX_API void Push(Value v);		EASX_API Value Pop();		EASX_API unsigned int GetSize();		EASX_API Value Peek(unsigned int index);	private:		std::stack<Value> _stack;};


#include "IceStack.hpp"IceStack::IceStack(void){}IceStack::~IceStack(void){}void IceStack::Push(Value v){	//push the value on the stack	_stack.push(v);}Value IceStack::Pop(){	//if the stack is not empty, pop a value of the stack and return it	if(!_stack.empty())	{		Value v= _stack.top();		_stack.pop();		return v;	}	//if the stack is empty, return a empty value	else	{		return Value();	}}unsigned int IceStack::GetSize(){	//return the size	return _stack.size();}Value IceStack::Peek(unsigned int index){	//return the value	return _stack._Get_container().operator[](index);}
"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me

Zahlman
Zahlman
Quote:
Original post by assainator
The idea behind the Peek functionality is to quickly access any number of values on any place in the stack.


Wanting to do this means that you don't really want to use a stack.
SiCrane
SiCrane
It's a null pointer error. Use your debugger and look at the variables in each stack frame for a null pointer. My guess: the pointer to your IceStack object is null.
assainator
assainator
Quote:
Original post by Zahlman
Quote:
Original post by assainator
The idea behind the Peek functionality is to quickly access any number of values on any place in the stack.


Wanting to do this means that you don't really want to use a stack.

I forgot to add that this would only be used for debugging.

@SiCrane: Thanks for the advice, I will report what I find.
"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me

Zahlman
Zahlman
Quote:
Original post by assainator
I forgot to add that this would only be used for debugging.


Use the debugger for debugging.
assainator
assainator
I mean to debug scripts. If I want to debug a script, I don't want run it with msvc every time.

@ SiCrane: I have looked but the IceObject is always valid, I can look at the stack and see the values in it when debugging my app (with msvc). The code that I'm pointed to looks like this (taken from ):
void _Adopt(const _Container_base12 *_Parent)		{	// adopt this iterator by parent		if (_Parent != 0)			{	// have a parent, do adoption			_Container_proxy *_Parent_proxy = _Parent->_Myproxy; #if _ITERATOR_DEBUG_LEVEL == 2			if (_Myproxy != _Parent_proxy)				{	// change parentage				_Lockit _Lock(_LOCK_DEBUG);				_Orphan_me();				_Mynextiter = _Parent_proxy->_Myfirstiter; //this line causes the Access violation error				_Parent_proxy->_Myfirstiter = this;				_Myproxy = _Parent_proxy;				} #else /* _ITERATOR_DEBUG_LEVEL == 2 */			_Myproxy = _Parent_proxy; #endif /* _ITERATOR_DEBUG_LEVEL == 2 */			}		}

In that piece of code,
the parameter _Parent is a valid pointer (ie. not NULL)
it passes the first statement since it is not a NULL pointer
_Parent_proxy is assigned to a invalid pointer: 0x00000002
Since the debug level is 2 the next if-block is executed as well
The value _MyProxy is a NULL pointer
it passes the if statement since _Myproxy (0x00000000) != _Parent_proxy(0x00000002)
_Lock gets a value as it should,
_Orphan_me() is a valid function, it does not point into bad memory
_Mynextiter is NULL, but it could be not initialised yet, that it is in this line
_Parent_proxy is a pointer to 0x00000002


And I have absolutely no idea what to do with this.
Does anybody do have a idea what to do with this?

assainator
"What? It disintegrated. By definition, it cannot be fixed." - Gru - Dispicable me

"Dude, the world is only limited by your imagination" - Me

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.