* 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
[parent not found: <45BFD127.6040609@homemail.com.au>]
* Re: pthread_exit and STL problems [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> 0 siblings, 2 replies; 4+ messages in thread From: Stefan Eilemann @ 2007-01-31 9:02 UTC (permalink / raw) To: Ross Johnson; +Cc: Pthreads-Win32 list On 31. Jan, 2007, at 0:13 , Ross Johnson wrote: Hello Ross, > My C++ is very limited but I have a couple of general questions and > possibly redundant general comments. > > You're using pthreads-win32 2.8.0 but which version of the DLL are > you using, VC or VCE? I am using pthreadVC2. > Are you building the pthreads library from source? The packaged > dlls are built using VC6 and the BUGS file in the pthreads > distribution refers to problems relating to the VCE dll which may > or may not be VC version specific. I am using the packaged DLL. Since I am using the VC version, it is my understanding that this doesn't matter. > > Does trying any of the above alternatives avoid the problem? I've just tried to build the library myself using VC8.0. Using 'nmake clean VC' path failed, since the resulting library was referencing msvcrt80.dll, which the executable couldn't find. Converting the .dsw file in VS2005 and using it resulted in a usable library - though I am not sure which 'version' I have. __CLEANUP_C and PTW32_BUILD are defined. Can you enlighten me? Do I need to define __CLEANUP_C during my build as well? I am just a bit nervous using a library where I haven't fully grokked the side effects. Cheers, Stefan. -- http://www.equalizergraphics.com http://www.linkedin.com/in/eilemann ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: pthread_exit and STL problems 2007-01-31 9:02 ` Stefan Eilemann @ 2007-01-31 13:54 ` Streithorst, Kip [not found] ` <45C0A0B5.6040306@homemail.com.au> 1 sibling, 0 replies; 4+ messages in thread From: Streithorst, Kip @ 2007-01-31 13:54 UTC (permalink / raw) To: Stefan Eilemann, Ross Johnson; +Cc: Pthreads-Win32 list The reason the executable couldn't locate msvcrt80.dll is because you will have to install the Visual Studio 8 redistributable which can be found in " C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\vcredist_x86" of a Visual Studio install. Or you can read more at Microsoft's website. The other thing you have to do is embed the manifest into the pthreadVC2.dll after is generated. This is a new requirement Microsoft added for Visual Studio 8. Ross, The embedding of the manifest in the dll is another thing besides the warnings that has to be dealt with. Thanks, Kip -----Original Message----- From: pthreads-win32-owner@sourceware.org [mailto:pthreads-win32-owner@sourceware.org] On Behalf Of Stefan Eilemann Sent: Wednesday, January 31, 2007 4:00 AM To: Ross Johnson Cc: Pthreads-Win32 list Subject: Re: pthread_exit and STL problems On 31. Jan, 2007, at 0:13 , Ross Johnson wrote: Hello Ross, > My C++ is very limited but I have a couple of general questions and > possibly redundant general comments. > > You're using pthreads-win32 2.8.0 but which version of the DLL are > you using, VC or VCE? I am using pthreadVC2. > Are you building the pthreads library from source? The packaged > dlls are built using VC6 and the BUGS file in the pthreads > distribution refers to problems relating to the VCE dll which may > or may not be VC version specific. I am using the packaged DLL. Since I am using the VC version, it is my understanding that this doesn't matter. > > Does trying any of the above alternatives avoid the problem? I've just tried to build the library myself using VC8.0. Using 'nmake clean VC' path failed, since the resulting library was referencing msvcrt80.dll, which the executable couldn't find. Converting the .dsw file in VS2005 and using it resulted in a usable library - though I am not sure which 'version' I have. __CLEANUP_C and PTW32_BUILD are defined. Can you enlighten me? Do I need to define __CLEANUP_C during my build as well? I am just a bit nervous using a library where I haven't fully grokked the side effects. Cheers, Stefan. -- http://www.equalizergraphics.com http://www.linkedin.com/in/eilemann ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <45C0A0B5.6040306@homemail.com.au>]
[parent not found: <A75AD195-4E38-4A02-8979-A3EC3C568FB2@gmail.com>]
[parent not found: <45C1DFB1.6010508@homemail.com.au>]
* Re: pthread_exit and STL problems [not found] ` <45C1DFB1.6010508@homemail.com.au> @ 2007-02-02 9:11 ` Stefan Eilemann 0 siblings, 0 replies; 4+ messages in thread From: Stefan Eilemann @ 2007-02-02 9:11 UTC (permalink / raw) To: Ross Johnson; +Cc: Pthreads-Win32 list On 1. Feb, 2007, at 13:40 , Ross Johnson wrote: > Stefan Eilemann wrote: >> Yes - I tested the generated pthreadVC2.dll, and the crash >> disappeared. > That's great. I'll have to see if I can get myself an updated VS. To summarize: Using the VC8 compiler fixed the problem for me. I am using the VC8-build version of pthreadVC2 for a couple of days now in my project, without problems. In case I'll bump into an issue again, I'll let you know. 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).