From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29660 invoked by alias); 15 May 2006 13:22:07 -0000 Received: (qmail 29652 invoked by uid 22791); 15 May 2006 13:22:06 -0000 X-Spam-Check-By: sourceware.org Received: from Unknown (HELO anche.india.tejasnetworks.com) (164.164.94.83) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 15 May 2006 13:22:04 +0000 Received: from localhost (unknown [127.0.0.1]) by anche.india.tejasnetworks.com (*****) with ESMTP id 112397398E; Mon, 15 May 2006 13:19:32 +0000 (UTC) Received: from anche.india.tejasnetworks.com ([127.0.0.1]) by localhost (anche [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03952-05; Mon, 15 May 2006 18:49:30 +0530 (IST) Received: from india.tejasnetworks.com (unknown [192.168.90.88]) by anche.india.tejasnetworks.com (*****) with ESMTP id 9877B7396A; Mon, 15 May 2006 18:49:30 +0530 (IST) Message-ID: <446881A2.4060706@india.tejasnetworks.com> Date: Mon, 15 May 2006 13:22:00 -0000 From: Aseem Rastogi User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020408 MIME-Version: 1.0 To: Sanjib Talukdar Cc: gcc-help@gcc.gnu.org Subject: Re: Problem with Map Iterator References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-05/txt/msg00152.txt.bz2 could be because when u have erased the map node pointed to by iterMap, iterMap++ crashes as the memory location pointed to by iterMap becomes invalid. so, instead of erasing in loop, do a clear () on map after the loop. see inline. hope this helps. Sanjib Talukdar wrote: >Hi, > >I am getting a segmentation fault error while executing the following >code: > > if (!this->colDtlsByName.empty()) > { > std::map< std::string, CS_DATAFMT*, > std::less >::iterator iterMap; > for (iterMap = this->colDtlsByName.begin(); > iterMap != this->colDtlsByName.end(); ++iterMap) > { > CS_DATAFMT* obj = iterMap->second; > if (obj != NULL) > delete obj; > this->colDtlsByName.erase(iterMap); ///////// Remove this line > } > >>> call this->colDtlsByName.clear (); > > } > >The backtrace from gdb is as follows: > > #0 0xff0e29b4 in std::_Rb_tree_increment () from >/usr/sfw/lib/libstdc++.so.6 > #1 0x0009854c in std::_Rb_tree_iteratorconst, _cs_datafmt*> >::operator++ (this=0xfe77a0c4) at stl_tree.h:180 > #2 0x0005a84c in MACDBQueryHandler::clearColInfo >(this=0xfe77bd30, inType=ALL) > at MACDBQueryHandler.C:123 > >The above code is in the method MACDBQueryHandler::clearColInfo() which >is being invoked in the class destructor. >We are using gcc version 3.4.3 on Solaris 10. The library libstdc++.so.6 >is pointing to libstdc++.so.6.0.3. > >Can anyone please point out the reason for the error? >Thank You. >Sanjib. > -- Nothing will work if u don't.