Re: [Boost-bugs] [Boost C++ Libraries] #8538: asio: race condition for epoll & kpoll

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8538: asio: race condition for epoll & kpoll
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-05-14 21:40:02

#8538: asio: race condition for epoll & kpoll
  Reporter: Leonid Gershanovich <gleonid@…> | Owner: chris_kohlhoff
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: asio
   Version: Boost 1.53.0 | Severity: Problem
Resolution: | Keywords:

Comment (by Leonid Gershanovich <gleonid@…>):

 You are right, free_descriptor_state does not free memory, thus my initial
 statement that segfault can occur in mutex::scoped_lock dtor is incorrect.
 However, segfault does happen, although in slightly different place.

 in epoll_reactor::start_op you can see following code:
 217: mutex::scoped_lock descriptor_lock(descriptor_data->mutex_);
 219: if (descriptor_data->shutdown_)
 220: {
 221: post_immediate_completion(op);
 222: return;
 223: }

 If thread 1 executes epoll_reactor::deregister_internal_descriptor quoted
 in the begining, while thread 2 executes epoll_reactor::start_op above,
 thread 2 will segfaults on line 219 if thread 1 completes line 367
 (descriptor_data = 0) before thread 2 starts executing line 219.
 That was actually the problem I have initially ran into. Sorry for
 confusion, I should have initially described the exact problem I had.

 Patch that I have attached on May 1st covers that.

 While I completely agree with "It would be unfortunate if applications had
 to pay for additional locking overhead when using a single thread or if
 the underlying sockets already provide thread-safety".
 I just like to point out that mutexes are already in asio code, my patch
 neither introduce any new locks nor makes locked section longer.

Ticket URL: <>
Boost C++ Libraries <>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC