Subj : Re: Linux thread weird problem.. To : comp.programming.threads From : ranjeetw Date : Sun Jul 10 2005 04:34 am Hi Joe, Sorry, just forgot to give update. I have solution. Thanks for all the help. (I am posting what the solution is, though it is not related to threads, just in case somebody is interested. Though, initially I thought, it is synchronization issue.) The trouble was, I adopted a lazy approach to the compare function for map where I needed to handle 4 different strings as key. This resulted in the endless loop when erase was called on the map. struct mycomparefunction { bool operator()(const node s1, const node s2) { if (strcmp( s1.source_addr , s2.source_addr ) < 0) return true; else if (strcmp( s1.dest_addr, s2.dest_addr ) < 0) return true ; else if (strcmp( s1.msg_id, s2.msg_id ) < 0 ) return true ; else if( strcmp(s1.device_id < s2.device_id) < 0 ) return true ; else return false ; } }; Whereas it should have been... struct mycomparefunction { bool operator()(const node s1, const node s2) { int result = strcmp( s1.source_addr , s2.source_addr ); if ( result < 0) return true; else if (result > 0) return false; result = strcmp( s1.dest_addr, s2.dest_addr ); if ( result < 0) return true ; else if (result > 0) return false; result = strcmp( s1.msg_id, s2.msg_id ); if ( result < 0 ) return true ; else if (result > 0) return false; else if( strcmp(s1.device_id < s2.device_id) < 0 ) return true ; else return false ; } }; Thanks again, HTH somebody, RS. Joe Seigh wrote: > ranjeetw@gmail.com wrote: > > > > I have single thread handling this data in std::map. This thread waits > > on select, and gets notified from other threads through pipe (as > > mentioned earlier). Main thread wakes up, and processes requests. > > > > I am not creating any other thread. I am not passing any functions for > > callback. I am not supplying pointers to this std::map structures. This > > remains a mystery for me, why app should get in endless loop in STL lib > > only. > > > > The data structure was probably corrupted earlier, not at the point > you're seeing the problem. I don't have enough inforation and > am not familiar enough with STL to know what the problem is. One > problem is that "threadsafe as int" in C++ doesn't mean very much. > > > -- > Joe Seigh > > When you get lemons, you make lemonade. > When you get hardware, you make software. .