#8422 closed Bugs (fixed)
Assertion in win32::WaitForSingleObject()
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | Boost 1.54.0 | Component: | thread |
Version: | Boost 1.53.0 | Severity: | Problem |
Keywords: | assertion basic_timed_mutex win32 WaitForSingleObject | Cc: |
Description
I get the following assertion when I used Ctrl-C on an app:
Assertion failed: win32::WaitForSingleObject( sem,::boost::detail::win32::infinite)==0, file ...\boost\thread\win32\basic_timed_mutex.hpp, line 79
Examination of that line of code reveals that the error handling is insufficient. WaitForSingleObject()
can return WAIT_ABANDONED
if the lock is held when the owning thread is released. In non-debug builds, this means the code falls through to the next statement in such cases, whereas in debug BOOST_VERIFY
reports an error. Either way, WAIT_ABANDONED
should be handled.
(Refer to http://msdn.microsoft.com/en-us/library/windows/desktop/ms687032.aspx for details on the API.)
Change History (8)
comment:1 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 9 years ago
Since that return value means the calling thread owns the mutex by default of the previous owner, it should be treated as equivalent to WAIT_OBJECT0
. Thus, the following seems appropriate:
DWORD const retval(win32::WaitForSingleObject(sem, ::boost::detail::win32::infinite)); BOOST_VERIFY(WAIT_OBJECT0 == retval || WAIT_ABANDONED == retval);
You might prefer to repackage WAIT_ABANDONED
like WAIT_TIMEOUT
is, so the following may be more in keeping with the current code:
DWORD const retval(win32::WaitForSingleObject(sem, ::boost::detail::win32::infinite)); BOOST_VERIFY(0 == retval || ::boost::detail::win32::abandoned == retval);
comment:5 by , 9 years ago
Milestone: | To Be Determined → Boost 1.54.0 |
---|
comment:7 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
What would be the expected behavior when WaitForSingleObject() returns WAIT_ABANDONED?