Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#8422 closed Bugs (fixed)

Assertion in win32::WaitForSingleObject()

Reported by: robert.stewart@… 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 viboes, 10 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

What would be the expected behavior when WaitForSingleObject() returns WAIT_ABANDONED?

comment:2 by viboes, 9 years ago

ping?

comment:3 by robert.stewart@…, 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:4 by viboes, 9 years ago

Yes, this can be changed. I will do it soon.

comment:5 by viboes, 9 years ago

Milestone: To Be DeterminedBoost 1.54.0

comment:6 by viboes, 9 years ago

Committed in trunk [84710]

comment:7 by viboes, 9 years ago

Resolution: fixed
Status: assignedclosed

comment:8 by viboes, 9 years ago

Committed revision [84750].

Note: See TracTickets for help on using tickets.