Jump to content
  • Advertisement
Sign in to follow this  
p0is0n

Strange std::Vector problem

This topic is 3281 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
What is the element type of the vector? Does that type contain pointers? If so, does it follow the rule of three?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sounds like something is keeping hold of an iterator after a resize or other operation that invalidates all iterators.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!