Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wrote a MFC application program in VS2010 IDE.I used some STL containers such as vector,map ,etc.But after ruuning my program,the program crashed.The error message said "map/set iterator not dereferencable!".So what shoud I do can find where the code caused the crash?How to locate the "bug"?Thank you very much!

What I have tried:

I had a try according to the ways fron the Internet,but I couldn't find the "bug"!!!So what should I do...
Posted
Updated 24-Jul-17 22:50pm
Comments
Richard MacCutchan 25-Jul-17 4:49am    
Look at all the places in your code where you are trying to dereference an iterator.
Mark Danniel 25-Jul-17 5:15am    
Thanks for answering!

1 solution

Use the debugger.
Run your app in the debugger - it's pretty simple, google will find you instructions - and when it crashes, use the stack trace to locate the function in your code that made it crash.
Put a breakpoint at the top of the function, and your your app again. This time, it will stop when it enters the function and let you take control. You can now step through the code, looking at variable contents and working out what is going on.

Sorry, but we can't do that for you: we don't have access to your code or data, and wouldn't know how to use it if we did!
 
Share this answer
 
Comments
Mark Danniel 25-Jul-17 5:08am    
Thanks a lot! I'll have a try.I have a question:The debugger you mentioned previously is the VS2010 Debug mode of the IDE ?And you said "google will find you instructions" I don't understand this. Could you please explain for the detail?
OriginalGriff 25-Jul-17 5:20am    
Yes.
And I mean "if you don't know how to use the debugger, Google will give you much better instructions than I can in a little text box". :laugh:
Mark Danniel 25-Jul-17 5:25am    
Got it!Thanks very much! :laugh:
OriginalGriff 25-Jul-17 5:32am    
You're welcome!
Mark Danniel 25-Jul-17 23:27pm    
I have solved the problem with the help of you.I found the reason caused the crash.There was a map clear operation before using the map iterator,causing the iterator unavailable... So I would be much more cautious.Thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900