Boost C++ Libraries: Ticket #9817: Boost Asio + Visual Studio 2013 crashes without BOOST_ASIO_DISABLE_IOCP https://svn.boost.org/trac10/ticket/9817 <p> In a Visual Studio 2013 SP1 Project with 8 executables using boost asio, 1 of them crashes in a repetitive way, always at the same point. The problem is related to memory management and code generation when win_iocp_socket_service is used. For example the following code, under very special circumstances, may trigger the crash: </p> <pre class="wiki"> tcp::iostream * sss = new tcp::iostream("mysite.com", "80"); </pre><p> I realized that everytime it crashes, win_iocp_io_service constructor is not called. Hence iocp_.handle is not initialized and is later used in <a class="missing wiki">CreateIoCompletionPort</a>() containing garbage, this being the ultimate reason of the crash. </p> <p> On the other hand, in the processes that work, the constructor is properly called, as it should always be. =&gt; Is there any known possibility for win_iocp_io_service constructor not being called? Is there anything like a default constructor that could be called instead? </p> <pre class="wiki"> main() { tcp::iostream * sss = new tcp::iostream("mysite.com", "80"); } </pre><p> The code won't crash. But the following may do if <a class="missing wiki">MyClass</a> instantiates boost::asio::io_service </p> <pre class="wiki"> MyClass * myInstance = NULL; main() { if(myInstance) delete myInstance; tcp::iostream * sss = new tcp::iostream("mysite.com", "80"); } </pre><p> Don't expect to be able to reproduce it this way, as I said it's difficult to isolate because it probably is related to a bug in the compiler that only manifests in very special conditions that boost asio sometimes trigger. Simply moving lines of code may fix it. </p> <p> The problem is not in memory management in our source code, that was my first thought, but all tests suggest it isn't. In addition, the code has been working for years with boost 1.45 and GCC 4.5. The only change was moving to Visual Studio 2013 and boost asio 1.55. </p> <p> To corroborate, I was able to reproduce in a surrealistic way: just adding or commenting a line in dead code (code that can never be reached because it is placed after a return) would fix or make the application crash. </p> <p> Finally I solved everything by defining BOOST_ASIO_DISABLE_IOCP. I didn't change a single line of code. No more crashes since then. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9817 Trac 1.4.3