public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* pthread_exit and STL problems
@ 2007-01-30  9:20 Stefan Eilemann
       [not found] ` <45BFD127.6040609@homemail.com.au>
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Eilemann @ 2007-01-30  9:20 UTC (permalink / raw)
  To: Pthreads-Win32 list

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<Object*>::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<eqNet::Object  
*,std::allocator<eqNet::Object *> >::_Orphan_range(eqNet::Object * *  
_First=0x0038c830, eqNet::Object * * _Last=0x0038c834)  Line 1233 +  
0x5 bytes
Equalizer.dll!std::vector<eqNet::Object  
*,std::allocator<eqNet::Object *> >::erase 
(std::_Vector_iterator<eqNet::Object *,std::allocator<eqNet::Object  
*> > _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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-02-02  9:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-30  9:20 pthread_exit and STL problems Stefan Eilemann
     [not found] ` <45BFD127.6040609@homemail.com.au>
2007-01-31  9:02   ` Stefan Eilemann
2007-01-31 13:54     ` Streithorst, Kip
     [not found]     ` <45C0A0B5.6040306@homemail.com.au>
     [not found]       ` <A75AD195-4E38-4A02-8979-A3EC3C568FB2@gmail.com>
     [not found]         ` <45C1DFB1.6010508@homemail.com.au>
2007-02-02  9:11           ` Stefan Eilemann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).