Opened 10 years ago

Closed 10 years ago

#7755 closed Bugs (fixed)

Thread: deadlock with shared_mutex on Windows

Reported by: Andrey <nikolay@…> Owned by: viboes
Milestone: Boost 1.54.0 Component: thread
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc: viboes

Description

Please see attached test. Code is very simple. It works when thread3 uses thread3_func_workaround function and test is deadlocked when thread3 uses thread3_func function. From the first view, it seems the problem in the shared_mutex::timed_lock function. Possible it have to signal "semaphores[unlock_sem]" semaphore when state.exclusive_waiting_blocked is changed from true to false. This action will wake up threads which are waiting for shared access.

P.S. I didn't try the same test using pthread, so it is a good idea to test (and fix if needed) pthread implementation as well.

Attachments (2)

shared_mutex_deadlock.zip (3.8 KB ) - added by Andrey <nikolay@…> 10 years ago.
7755.patch (2.2 KB ) - added by viboes 10 years ago.

Download all attachments as: .zip

Change History (9)

by Andrey <nikolay@…>, 10 years ago

Attachment: shared_mutex_deadlock.zip added

comment:1 by viboes, 10 years ago

Cc: viboes added
Owner: changed from Anthony Williams to viboes
Status: newassigned

Hi, since 1.50 there is the possibility to use a common implementation for shared_mutex defining BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN or BOOST_THREAD_VERSION=3.

Please, could you tell me if this solves the issue?

See #4882.

comment:2 by Andrey <nikolay@…>, 10 years ago

Defining BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN solves the issue!!!

comment:3 by viboes, 10 years ago

Milestone: To Be Determined
Resolution: duplicate
Status: assignedclosed

comment:4 by viboes, 10 years ago

Milestone: To Be Determined
Resolution: duplicate
Status: closedreopened

Reopened as BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN will not be defined by default and as #7906 states there is a lost in performances when this define is defined.

by viboes, 10 years ago

Attachment: 7755.patch added

in reply to:  description comment:5 by anonymous, 10 years ago

Replying to Andrey <nikolay@…>:

Please see attached test. Code is very simple. It works when thread3 uses thread3_func_workaround function and test is deadlocked when thread3 uses thread3_func function. From the first view, it seems the problem in the shared_mutex::timed_lock function. Possible it have to signal "semaphores[unlock_sem]" semaphore when state.exclusive_waiting_blocked is changed from true to false. This action will wake up threads which are waiting for shared access.

It seems your analysis were right. Please could you try the attached patch?

comment:6 by viboes, 10 years ago

Milestone: To Be DeterminedBoost 1.54.0

comment:7 by viboes, 10 years ago

Resolution: fixed
Status: reopenedclosed

Committed revision [83525].

Note: See TracTickets for help on using tickets.