Re: Stack Overflow crash while inserting in std::map after migration to VS2005 (VC8)
Jerry Coffin wrote:
In article <uo7y46RCIHA.1168@TK2MSFTNGP02.phx.gbl>,
gangasridhar@abosoftware.com says...
[ ... ]
I keep getting these crashes - First-chance exception at 0x1057b4eb
(Std32.dll) in TransService.exe: 0xC00000FD: Stack overflow.
Are you certain it's really crashing at all? A first-chance exception
doesn't necessarily mean anything has gone wrong at all. It's a
perfectly normal part of how the virtual memory system works.
Any time you see a stack overflow exception, it's a problem - first chance,
or no. I don't believe that the soft page faults that are used to commit
the stack range are visible to the application, even as first-chance
exceptions.
When/if this exception is not handled, and you see it as a _second-
chance_ exception, then you know there's really a problem. Until or
unless that happens, all that's going on is that the current stack
allocation is being exhausted, and more memory needs to be added to
the stack. That's a perfectly normal, everyday occurence and nothing
to worry about at all.
Even if the application is crashing, this is probably NOT the cause.
In all likelihood, the real problem is improper control of access to a
shared data structure from multiple threads. For example,. simultaneous
inserts into (or deletes from) a single std::map from two threads at once.
It's not unlikely that such access would result in a corrupted internal
state of the map. Since a map is implemented as a red-black tree, it's
likely that a loop has been produced somewhere in the tree so that a
recursive search routine (that normally will bail out after only a few
iterations) instead becomes unbounded recursion resulting in the stack
overflow.
-cd