Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 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.)

Attachments (0)

Change History (8)

comment:1 Changed 4 years ago by viboes

Owner: changed from Anthony Williams to viboes
Status: newassigned

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

comment:2 Changed 4 years ago by viboes

ping?

comment:3 Changed 4 years ago by robert.stewart@…

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 Changed 4 years ago by viboes

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

comment:5 Changed 4 years ago by viboes

Milestone: To Be DeterminedBoost 1.54.0

comment:6 Changed 4 years ago by viboes

Committed in trunk [84710]

comment:7 Changed 4 years ago by viboes

Resolution: fixed
Status: assignedclosed

comment:8 Changed 4 years ago by viboes

Committed revision [84750].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain viboes.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.