title: What are some useful tips to track down a randomly occuring C0000005 Access Violation in C++?
body: <p>I have done some searches on here, MSDN, and through some other forums via Google trying to find any sort of solution to this, but so far am stuck.</p>
  
  <p>I have been looking for a week, trying to track down an access violation error in my C++ Program. I cant really post code here as it is under some IP Restrictions, but basically, it is a loop that is running roughly every 100ms reading bytes from a TCP Connection and placing them onto the back of a std::queue.</p>
  
  <p>After I notice a particular byte sequence come through, I then remove x bytes from the queue and handle them as a message defined in an internal protocol.</p>
  
  <p>What happens is, somewhere inside my application, the queue is becoming corrupted and crashing the application. So pair that with the fact that it is an access violation, it must be a dodgy pointer somewhere.</p>
  
  <p>I have tried to use the VS2005 Debugger and Windbg to find it, I had call stacks to look at but it wasnt much help. All I could work out from it is that the cause is corruption of my internal queue. The reason it crashes is because the header of the message gets send to be parsed, but because it is corrupted everything falls over.</p>
  
  <p>Then I tried Intel Thread Checker but that is far too slow to use in this application, as my program is part of a synchronous multi-threaded system.</p>
  
  <p>Sometimes it will run for 300 reads... sometimes it can do 5000 reads... sometimes it can do 10000 reads before it crashes.</p>
  
  <p>What are some other routes of diagnosis I can try? Am I missing something simple here that I should have checked already? From what I can see, anything being newed has a matching delete, and I am using Boost Librarys for Shared Pointers and Auto Pointers on long-living objects.</p>