Modify

Opened 7 years ago

Closed 6 years ago

#5859 closed Bugs (fixed)

win32 shared_mutex constructor leaks on exceptions

Reported by: phrosty@… Owned by: viboes
Milestone: Boost 1.49.0 Component: thread
Version: Boost 1.47.0 Severity: Problem
Keywords: shared_mutex Cc: viboes

Description

shared_mutex's contructor contains three calls to create_anonymous_semaphore(), each of which can throw. If one of these throws, the unprotected handles of the previous ones will leak.

Attachments (0)

Change History (5)

comment:1 Changed 6 years ago by viboes

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

Thanks for this report. I will try to solve it soon.

comment:2 Changed 6 years ago by viboes

In order to avoid a chained try-catch a no_throw create_anonymous_semaphore_nothrow function can be used like in

            if (!semaphores[exclusive_sem])
            {
              detail::win32::release_semaphore(semaphores[unlock_sem],LONG_MAX);
              boost::throw_exception(thread_resource_error());
            }
            upgrade_sem=detail::win32::create_anonymous_semaphore_nothrow(0,LONG_MAX);
            if (!upgrade_sem)
            {
              detail::win32::release_semaphore(semaphores[unlock_sem],LONG_MAX);
              detail::win32::release_semaphore(semaphores[exclusive_sem],LONG_MAX);
              boost::throw_exception(thread_resource_error());
            }

While this is not too elegant it solves the issue. A RAI handle would be also appreciated.

comment:3 Changed 6 years ago by viboes

Milestone: To Be DeterminedBoost 1.49.0
Resolution: fixed
Status: assignedclosed

Committed in trunk At revision: [75806]

Last edited 5 years ago by viboes (previous) (diff)

comment:4 Changed 6 years ago by viboes

Resolution: fixed
Status: closedreopened

Let close the ticket when merged to release

comment:5 Changed 6 years ago by viboes

Resolution: fixed
Status: reopenedclosed

Committed in release at [76291]

Last edited 5 years ago by viboes (previous) (diff)

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.