Opened 6 years ago

Closed 5 years ago

#12547 closed Bugs (fixed)

yield_completion in fibers possibly destroys busy mutex

Reported by: Thadeu Luiz Barbosa Dias <thadeuluiz@…> Owned by: olli
Milestone: To Be Determined Component: Documentation
Version: Boost 1.62.0 Severity: Problem
Keywords: Cc:

Description

Im using something similar to this page:

http://www.boost.org/doc/libs/1_62_0/libs/fiber/doc/html/fiber/callbacks/then_there_s____boost_asio__.html

in my project but it contains a bug. yield_completion::wait() does not reacquire the lock before returning, therefore async_result_base::get() and async_result<T>::get() might return before the notifying thread(calling async_handler::operator() releases the lock. with that, async_result<T> might be destroyed while the lock is being held by the notifying thread causing a crash.

I assumed that the lock gets reacquired on fiber resume, but that is not the case, lk.owns_lock() is false after the suspend statement. the solution is to simply call lk.lock() after the suspend call on the context.

Change History (2)

comment:1 by Kohei Takahashi, 6 years ago

Owner: changed from Matias Capeletto to olli

comment:2 by olli, 5 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.