Strange std::Vector problem

Started by
4 comments, last by p0is0n 14 years, 10 months ago
Hi all, I have written a small wrapper for ASSIMP (3D model loading lib) that converts it to my own model format. I get an error when it tries to resize a std::vector, the values going into resize are perfectly fine. The code for ASSIMP is sound, but it still crashes with : Debug Assertion Failed! Expression : vector insert iterator out range The real problem is that I have 2 other projects that the exact same code works perfectly fine in. I just created a project that simply has :

#include <Windows.h>
#include "ModelImporter.hpp"

//The win main
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	ModelImporter mi;
	M_Model model;
	if(! mi.Load("Shuttle01.3DS", model)) return -1;

	return 0;
}

And that works fine, but in just one project (where the files and lib files were copied from to create the above) crashes with the debug assertion error. Does anyone have any ideas as to what could cause this? As I mentioned the code above from ModelImporter and the Assimp library and library files, and the model files were copied to the project above from the project that gives this error.
Advertisement
What is the element type of the vector? Does that type contain pointers? If so, does it follow the rule of three?
I'm having trouble finding that information right now as it is inside the lib that I'm using. I have the source for it somewhere, and will post with the type when I find it.
Sounds like something is keeping hold of an iterator after a resize or other operation that invalidates all iterators.
Quote:Original post by Evil Steve
Sounds like something is keeping hold of an iterator after a resize or other operation that invalidates all iterators.


I just don't understand why it would work in two projects, but not in another with exactly the same code. I even tried moving the code in the broken project to the start of WinMain and got the same problem.

Any ideas of what to look for to find the source of this problem?

Thanks.

Oh and the element type of the vector being resized is unsigned int. so there are no pointer problems there.
I have downloaded the latest source for the lib and recompiled it.
Now the project works just fine. It is really strange, because I compared the old and new files and while they were different the line that used to cause the error was the same. :S

All I can guess is that EvilSteve was right and something in the lib was invalidating the iterators. I still don't understand why it only happened in my DX10 project, but not my OpenGL or test windows only project. :S

Oh well as long as it works now all is good.
Thanks for the help.

This topic is closed to new replies.

Advertisement