For Programmers: Free Programming Magazines  


Home > Archive > VC STL > January 2006 > STL::map insert hangs









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author STL::map insert hangs
Jasleen

2006-01-09, 11:10 pm

Is it possible that STL::map hangs while inserting an element?
If yes, then under what conditions this can happen.I am using VC++.



Also if in the immediate window I want to traverse the map and view the
elements.
I write
mymap.begin()->first

It says - ambigous symbol.How shud I use begin method in the Immediate
window, while debugging?


Ulrich Eckhardt

2006-01-09, 11:10 pm

Jasleen wrote:
> Is it possible that STL::map hangs while inserting an element?


Yes.

> If yes, then under what conditions this can happen.I am using VC++.


It makes a call to an allocator which accesses the memory management which
needs synchronization. IOW, this is a blocking call that could
theoretically block infinitely. However, I can't generally imagine a case
where this would happen and in particular never came across one.

> Also if in the immediate window I want to traverse the map and view the
> elements.
> I write
> mymap.begin()->first
>
> It says - ambigous symbol.How shud I use begin method in the Immediate
> window, while debugging?


Please elaborate what you are doing and what you expect, the info you give
only allows guessing.

Uli

Stephen Howe

2006-01-09, 11:10 pm

> Is it possible that STL::map hangs while inserting an element?

Yes

> If yes, then under what conditions this can happen.I am using VC++.


If _you_ have corrupted the heap earlier on to the point that the heap
allocator when allocating memory for an element to do so, cannot continue.
So map is innocent but something else earlier is guilty.

Stephen Howe


Carl Daniel [VC++ MVP]

2006-01-09, 11:10 pm

Jasleen wrote:
> Is it possible that STL::map hangs while inserting an element?
> If yes, then under what conditions this can happen.I am using VC++.


In addition to other replies about the heap, it's probably possible that if
your ordering isn't a strict weak ordering that insert could end up stuck.
Are you sure you're using a strict-weak ordering?

> Also if in the immediate window I want to traverse the map and view
> the elements.
> I write
> mymap.begin()->first
>
> It says - ambigous symbol.How shud I use begin method in the Immediate
> window, while debugging?


Which version of VC++ are you using?

-cd


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com