Open AdrianDC opened 5 years ago
Hey @AdrianDC, this is awesome, thanks for putting it together. I'm not sure I'm going to have spare capacity any time soon to help look into this.
Latest version of Stability: Add stability test example and start multithreaded fixes
:
served: ensure multithreaded servers are properly released
* A class destructor is added to properly release the members
* The threads are joined upon destruction to ensure work is done
* A 1 millisecond delay is added to avoid multithreading races
* Threads are create with "bind" references rather than lambdas
The introduction of the 1 ms delay makes the cleanup safe on the CentOS 7.6 target, the previously shared unit test performs correctly over 10000 iterations.
The Debian one looks still affected though.
Playing around the allocations of the io_service related members, and manually releasing the object's memory did not give any difference. The only situation without failures is by "not" releasing the io_service member, hence leaking memory over each new running server.
Served server generates random segmentation faults (SIGSEGV) upon cleanups, due to race conditions throughout the Boost ASIO io_service destructors.
The issue can be proven with the new "stability" example sources (PR #53), iterating through 1000 creations of
served::net::server
with explicitstop()
calls and through 1000 creations ofserved::net::server
without callingstop()
.The issue can be easily reproduced in CentOS 7.6.1810 or Debian 10 Stable Docker images :
The random segmentation fault's backtrace are :