Opened 9 years ago

Closed 9 years ago

#8536 closed Bugs (invalid)

Repeated shared_mutex.unlock_shared() can underflow

Reported by: Zack Moratto <zmoratto@…> Owned by: Anthony Williams
Milestone: To Be Determined Component: thread
Version: Boost 1.53.0 Severity: Problem
Keywords: shared, mutex, underflow Cc:

Description

Boost 1.53's shared_mutex can underflow if the user calls unlock_shared twice or right after construction.

shared_mutex m();
m.unlock_shared();

The problem is specifically this line which can be found inside boost/thread/pthread/shared_mutex.hpp. (should be line 148)

            bool const last_reader=!--state.shared_count;

It doesn't check that state.shared_count is nonzero before decrementing.

Change History (1)

comment:1 by viboes, 9 years ago

Resolution: invalid
Status: newclosed

This is not a bug. It is a precondition that the mutex must be locked when you use unlock.

Note: See TracTickets for help on using tickets.