Hi Emmanuel Without more details on the error, I'll try to make a guess:
The destructor of HandleHolder calls HandleHolder::close() which in turn calls ::CloseHandle() Quoting MSDN: " If the function fails, the return value is zero. To get extended error information, call GetLastError. If the application is running under a debugger, the function will throw an exception if it receives either a handle value that is not valid or a pseudo-handle value. This can happen if you close a handle twice, or if you call CloseHandle on a handle returned by the FindFirstFile function. " You could try to have a look at the error code, if any, set by the call to ::CloseHandle() Also, NULL values are not tested before CloseHandle() is called. I had already spotted a bug in OpenThreads a year ago because it would not check for NULLs in operator bool(). Now it appears that the methods HandleHolder::close() and HandleHolder::set() do not check for NULL values either. I can't find a good reason why Microsoft uses two different values (NULL and INVALID_HANDLE_VALUE, which is ~0) to represent an invalid handle (*), but it's worth having a look at those two functions and see if adding checks for NULL values resolves the bug - or at least, makes sense. (*) Hidden somewhere in MSDN is the following sentence "If a NULL value or an INVALID_HANDLE_VALUE value is passed, the handle is clearly invalid" Anyway, IMHO using Mutexes on the stack is dangerous because the object can go out of scope (if an exception is thrown for instance, or simply because of an ill-designed program flow) while other threads are waiting on it. Multithreading is cool, but it's often very hard to track down all the possible code paths - and even more frustrating when the bug will not show up when stepping the code with a debugger. But if you post some minimal code that triggers the bug, I'd be glad to help. Good luck :) Thibault On 4/4/07, Emmanuel Roche <[EMAIL PROTECTED]> wrote:
hmmm... well, in fact, the same happens with the release version of OpenThreads... I guess I have a big problem somewhere, but I don't see how you could help :-( snif... I starting to hate multithreading... lol Emmanuel. ---------- Forwarded message ---------- From: Emmanuel Roche <[EMAIL PROTECTED]> Date: 4 avr. 2007 14:31 Subject: Error deleting Win32MutexPrivateData in OpenThreadsWin32d.lib To: OSG Users <[email protected]> Hello there, I'm trying to build a full debug version of my application, and I'm facing a strange problem : when linking againsthe debug version of OpenThreads on windows, I have an error in the HandleHolder destructor (in handleholder.h) when deleting some OpenThreads::Mutex objects. The problem apparently doesn't happen if I use new/delete instead of objects on the stack, butI cannot use the heap everywhere ! and, in addition, some other objects containing a mutex on the stack lead to the same problem (for example when destroying an osg::Block...) Did anyone already faced this problem ? if yes, how do I solve this ?... regards, Emmanuel _______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
