From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16692 invoked by alias); 30 Jan 2007 09:20:26 -0000 Received: (qmail 16683 invoked by uid 22791); 30 Jan 2007 09:20:26 -0000 X-Spam-Check-By: sourceware.org Received: from nz-out-0506.google.com (HELO nz-out-0506.google.com) (64.233.162.227) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 30 Jan 2007 09:20:19 +0000 Received: by nz-out-0506.google.com with SMTP id m7so1555382nzf for ; Tue, 30 Jan 2007 01:20:18 -0800 (PST) Received: by 10.64.208.20 with SMTP id f20mr11592850qbg.1170148817327; Tue, 30 Jan 2007 01:20:17 -0800 (PST) Received: from ?10.1.1.4? ( [89.217.55.55]) by mx.google.com with ESMTP id q16sm7264266qbq.2007.01.30.01.20.15; Tue, 30 Jan 2007 01:20:16 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <3D7E7834-79B3-4C11-BA29-DBF2821B8B6B@gmail.com> Content-Transfer-Encoding: 7bit X-Image-Url: http://www.equalizergraphics.com/images/me-64.png From: Stefan Eilemann Subject: pthread_exit and STL problems Date: Tue, 30 Jan 2007 09:20:00 -0000 To: Pthreads-Win32 list X-Mailer: Apple Mail (2.752.3) X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2007/txt/msg00011.txt.bz2 Hi, I am tracking down a problem in my code using VC++ 8.0 and pthreads-win32 2.8.0. My hope is that somebody on the list has seen (and solved) this problem. In my code I am removing elements from a std::vector<>, which works fine until the first pthread has exited. After this point, I am getting a crash in the debug version when erasing an element from the vector: vector::iterator iter = find( objects.begin(), objects.end(), object ); if( iter == objects.end( )) return; objects.erase( iter ); This is the call stack: Equalizer.dll!std::vector >::_Orphan_range(eqNet::Object * * _First=0x0038c830, eqNet::Object * * _Last=0x0038c834) Line 1233 + 0x5 bytes Equalizer.dll!std::vector >::erase (std::_Vector_iterator > _Where=0x00395fe0 {_initData={...} _frameData={...} _displayLists={...} }) Line 990 Equalizer.dll!eqNet::Session::removeRegisteredObject(eqNet::Object * object=0x00395fe0, eqNet::Object::SharePolicy policy=SHARE_NODE) Line 304 + 0x29 bytes Equalizer.dll!eq::Node::_cmdDestroyPipe(eqNet::Command & command= {...}) Line 134 C++ The code in question seems to invalidate all iterators of the vector. The crash happens because _Pnext gets an invalid pointer after some iterations: #if _HAS_ITERATOR_DEBUGGING void _Orphan_range(pointer _First, pointer _Last) const { // orphan iterators within specified (inclusive) range _Lockit _Lock(_LOCK_DEBUG); const_iterator **_Pnext = (const_iterator **)&this->_Myfirstiter; while (*_Pnext != 0) if ((*_Pnext)->_Myptr < _First || _Last < (*_Pnext)->_Myptr) _Pnext = (const_iterator **)&(*_Pnext)->_Mynextiter; else { // orphan the iterator (*_Pnext)->_Mycont = 0; *_Pnext = (const_iterator *)(*_Pnext)->_Mynextiter; } } #endif /* _HAS_ITERATOR_DEBUGGING */ Again - this code is called numerous time before without problem. The first time the crash happens is when a pthread has been exit'ed, and the calling thread just called pthread_join() shortly before the call above. I am linking against the multithreaded debug runtime. Has anybody seen this already? Does the thread exit code cleanup/ interfere with the VC8 STL implementation? Any hints? Cheers, Stefan. -- http://www.equalizergraphics.com http://www.linkedin.com/in/eilemann