   AV when enum display modes
  Hi guys!I've written a simple enumeration function as part of my classes. I am just confused becouse i get an av whether i don't see any error?!void Direct3D::get_supported_resolution(std::vector< resolution_t > & data){data.clear();D3DDISPLAYMODE mode;std::size_t count(m_lpDirect3D->GetAdapterModeCount(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8));for (std::size_t i = 0; i < count; ++i){if (FAILED(m_lpDirect3D->EnumAdapterModes(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8, static_cast<UINT>(i), &mode)))continue;resolution_t cur(std::make_pair(mode.Width, mode.Height));if (cur.first >= 800 && cur.second >= 600 && std::find(data.begin(), data.end(), cur) == data.end())data.push_back(cur);}}Any one a suggestion what could be the mistake?   
  Instead of asking us to mentally execute your code, why don't you step through it in the debugger to find out where the access violation is occurring.   ;  In addition to what legalize said; are you sure m_lpDirect3D is valid and non-null?   ;  Yes I am sure. I debugged the code already. The problem is curious ... I call the function like this:std::vector< graphic::resolution_t > data;graphic::Direct3D::instance().get_supported_resolution(data);. The av is no shown, wenn the data(std::vector)-object is destroved! The debugger shows a call of detroy_range ... but when i don't call the function, i don't get problems with the data-object. In addition i tested the same code in another project => same av ...any idea?   ;  What is the exact access violation? Reading or writing? What address? Does resolution_t have a destructor? What members does resolution_t have?   ;  Ahh sorry that i've fergotten to show you this informations:typedef resolution_t std::pair<std::size_t, std::size_t>; ok this part is the logical consequence of resolution_t cur(std::make_pair(mode.Width, mode.Height)); ... ;)the av occours at_Destroy_range(_First, _Last, _Al, _Ptr_cat(_First, _Last));(Standardlibrary-Implementation used by Visual C++ 2005) ... _First and _Al contain correct data but _Last contains some odd data.Visual C++ 2005 said:HEAP[XYZ.exe]: Invalid Address specified to RtlValidateHeap( 00EF0000, 00E67D98 ) ... any suggestions? I simply can't find the error :(   ;Quote:HEAP[XYZ.exe]: Invalid Address specified to RtlValidateHeap( 00EF0000, 00E67D98 )This isn't an access violation, this is the heap doing a consistency check and finding that the heap has been corrupted somehow.Use a tool like Purify, Bounds Checker, or the CRT debugging tools to identify where and how you've corrupted your heap.   ;  Also note that this is unrelated to that function - it just happens to occur here because when the vector is destroyed, it frees memory. You could also try sprinkling this over your code and see if it happens:delete new int;If it happens in one call and not in another, it's likely that the corruption happens between them. Check that you're not accessing deleted pointers or writing off the end of an array.   ;  I'd recommend putting this at the first line of main:_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF);What it will do is cause the runtime to check the entire heap for corruption at every new and delete. Your program will then stop at the first memory allocation after the heap has been corrupted.This can make your code run very slow if you do lots of allocation, so be patient. Alternatively just use the _CrtCheckMemory() asserts.To narrow it down even further you can add ASSERT(_CrtCheckMemory()); statements around the code. That will assert if the heap is corrupted so it'll let you narrow down the statement that corrupts the heap (i.e. find the statement where it doesn't assert before executing it, but does assert after).You may need to #include <crtdbg.h> for those to compile. Also make sure it's a debug build or they'll do nothing.See http://msdn2.microsoft.com/en-us/library/5at7yxcs(VS.71).aspx for more details.   ;  I added this function and the point where he shows a av moves a bit ... but still it is straight behind the call of >rcConfig.exe!std::allocator<std::pair<unsigned int,unsigned int> >::deallocate(std::pair<unsigned int,unsigned int> * _Ptr=(800,600), unsigned int __formal=28)  Line 141 + 0x9 bytesC++ ...Before there is no message of a corrupted heap! Any ideas?