Opened 11 years ago
Closed 11 years ago
#5859 closed Bugs (fixed)
win32 shared_mutex constructor leaks on exceptions
| Reported by: | 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.
Change History (5)
comment:1 by , 11 years ago
| Cc: | added | 
|---|---|
| Owner: | changed from to | 
| Status: | new → assigned | 
comment:2 by , 11 years ago
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 by , 11 years ago
| Milestone: | To Be Determined → Boost 1.49.0 | 
|---|---|
| Resolution: | → fixed | 
| Status: | assigned → closed | 
Committed in trunk At revision: [75806]
comment:4 by , 11 years ago
| Resolution: | fixed | 
|---|---|
| Status: | closed → reopened | 
Let close the ticket when merged to release
comment:5 by , 11 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | reopened → closed | 
Committed in release at [76291]
  Note:
 See   TracTickets
 for help on using tickets.
    

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