title: Need help with buffer overrun
body: <p>I've got a buffer overrun I absolutely can't see to figure out (in C).  First of all, it only happens maybe 10% of the time or so. The data that it is pulling from the DB each time doesn't seem to be all that much different between executions... at least not different enough for me to find any discernible pattern as to when it happens.  The exact message from Visual Studio is this:</p>
  
  <blockquote>
    <p>A buffer overrun has occurred in
    hub.exe which has corrupted the
    program's internal       state. Press
    Break to debug the program or Continue
    to terminate the program.</p>
    
    <p>For more details please see Help topic
    'How to debug Buffer Overrun Issues'.</p>
  </blockquote>
  
  <p>If I debug, I find that it is broken in <code>__report_gsfailure()</code> which I'm pretty sure is from the /GS flag on the compiler and also signifies that this is an overrun on the stack rather than the heap.  I can also see the function it threw this on as it was leaving, but I can't see anything in there that would cause this behavior, the function has also existed for a long time (10+ years, albeit with some minor modifications) and as far as I know, this has never happened.</p>
  
  <p>I'd post the code of the function, but it's decently long and references a lot of proprietary functions/variables/etc.</p>
  
  <p>I'm basically just looking for either some idea of what I should be looking for that I haven't or perhaps some tools that may help. Unfortunately, nearly every tool I've found only helps with debugging overruns on the heap, and unless I'm mistaken, this is on the stack.  Thanks in advance.</p>