Boost C++ Libraries: Ticket #7611: segfault in epoll_reactor.ipp https://svn.boost.org/trac10/ticket/7611 <p> During testing of versions 1.46.1 and 1.51 on a 64-bit Ubuntu 12.04 I have found a seg fault condition in epoll_reactor.ipp. </p> <p> The function is </p> <p> void epoll_reactor::deregister_descriptor(socket_type descriptor, </p> <blockquote> <p> epoll_reactor::per_descriptor_data&amp; descriptor_data, bool closing) </p> </blockquote> <p> { </p> <blockquote> <p> if (!descriptor_data) </p> <blockquote> <p> return; </p> </blockquote> </blockquote> <blockquote> <p> mutex::scoped_lock descriptor_lock(descriptor_data-&gt;mutex_); </p> </blockquote> <blockquote> <p> if (!descriptor_data-&gt;shutdown_) { </p> </blockquote> <p> The member descriptor_data is checked for NULL before the mutex is locked, in rare conditions, when the if-statement is reached, descriptor_data is NULL. </p> <p> I have solved this by adding a second check after the mutex is locked, i.e. </p> <blockquote> <p> if (!descriptor_data) </p> <blockquote> <p> return; </p> </blockquote> </blockquote> <blockquote> <p> mutex::scoped_lock descriptor_lock(descriptor_data-&gt;mutex_); </p> </blockquote> <blockquote> <p> if (!descriptor_data) </p> <blockquote> <p> return; </p> </blockquote> </blockquote> <blockquote> <p> if (!descriptor_data-&gt;shutdown_) { </p> </blockquote> <p> Best regards, Fredrik Jansson </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7611 Trac 1.4.3 nanyu@… Sun, 25 Nov 2012 18:34:02 GMT <link>https://svn.boost.org/trac10/ticket/7611#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:1</guid> <description> <p> yes, I meet this bug too. here is dump with gdb </p> <p> warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7fff405fc000 </p> <p> Core was generated by `./input_controller --id 0'. </p> <p> Program terminated with signal 11, Segmentation fault. </p> <p> <a class="missing ticket">#0</a> 0x00000000004155ca in boost::asio::detail::epoll_reactor::start_op (this=0x5f40390, op_type=0, descriptor=10, descriptor_data=@0x2aaab0000aa0, op=0x2aaaac002dc0, allow_speculative=true) </p> <blockquote> <p> at /usr/local/include/boost/asio/detail/impl/epoll_reactor.ipp:219 </p> </blockquote> <p> 219 if (descriptor_data-&gt;shutdown_) </p> <p> ... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Sat, 29 Dec 2012 09:21:22 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7611#comment:2 https://svn.boost.org/trac10/ticket/7611#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> The descriptor_data variable is only set to NULL when the corresponding socket is deregistered (see epoll_reactor::deregister_descriptor, which is in turn called from reactive_socket_service_base::destroy/close). This means that your program has closed the socket or destroyed the socket object. </p> <p> Most likely you have a threading issue in your program where you close a socket from one thread while simultaneously starting another async operation on the same socket from another thread. If you are sure this is not the case, please attach a small, complete program that exhibits the problem. Thanks. </p> Ticket jrob_email@… Thu, 30 Jan 2014 01:47:13 GMT <link>https://svn.boost.org/trac10/ticket/7611#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:3</guid> <description> <p> When was this bug introducted I see it in 1.45 Ubuntu 12.04 </p> <p> <a class="missing ticket">#0</a> 0x00002b55ee92fe84 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0 (gdb) bt <a class="missing ticket">#0</a> 0x00002b55ee92fe84 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> 0x00002b55ed7e1049 in lock (this=0x3233332ecb) at /usr/include/boost/asio/detail/posix_mutex.hpp:52 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a> scoped_lock (m=..., this=&lt;synthetic pointer&gt;) at /usr/include/boost/asio/detail/scoped_lock.hpp:36 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3" title="#3: Bugs: automatic conversion and overload proble (closed: fixed)">#3</a> boost::asio::detail::epoll_reactor::close_descriptor (this=0x3233332e53, descriptor_data=@0x51afeb2f0: 0x4f293a770) at /usr/include/boost/asio/detail/impl/epoll_reactor.ipp:195 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4" title="#4: Bugs: any_ptr in any library documentation? (closed: Fixed)">#4</a> 0x00002b55ee02d577 in destroy (impl=..., this=&lt;optimized out&gt;) at /usr/include/boost/asio/detail/impl/reactive_socket_service_base.ipp:53 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5" title="#5: Bugs: shared_ptr and self-owning objects (closed: Fixed)">#5</a> destroy (impl=..., this=&lt;optimized out&gt;) at /usr/include/boost/asio/datagram_socket_service.hpp:101 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6" title="#6: Bugs: tie in utility.hpp and tuple.hpp clash. (closed: Duplicate)">#6</a> ~basic_io_object (this=0x51afeb2e0, <span class="underline">in_chrg=&lt;optimized out&gt;) at /usr/include/boost/asio/basic_io_object.hpp:85 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7" title="#7: Bugs: g++ 2.96 requires NO_STRINGSTREAM (closed: Fixed)">#7</a> ~basic_socket (this=0x51afeb2e0, </span>in_chrg=&lt;optimized out&gt;) at /usr/include/boost/asio/basic_socket.hpp:1054 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8" title="#8: Bugs: prop in undirected graph + out_edges (closed: Works For Me)">#8</a> ~basic_datagram_socket (this=0x51afeb2e0, <span class="underline">in_chrg=&lt;optimized out&gt;) at /usr/include/boost/asio/basic_datagram_socket.hpp:41 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9" title="#9: Bugs: config_info ambiguity error (closed: Invalid)">#9</a> msg::kit::ChannelState::shutdown (this=0x51b969000) at UDPReceiver.cpp:1985 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/10" title="#10: Bugs: allyourbase.jam file is bad. (closed: Out of Date)">#10</a> 0x00002b55ee02d7cb in msg::kit::ChannelState::~<a class="missing wiki">ChannelState</a> (this=0x51b969000, </span>in_chrg=&lt;optimized o </p> </description> <category>Ticket</category> </item> <item> <author>jyu@…</author> <pubDate>Thu, 29 Dec 2016 18:21:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7611#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7611#comment:2" title="Comment 2">chris_kohlhoff</a>: </p> <blockquote class="citation"> <p> The descriptor_data variable is only set to NULL when the corresponding socket is deregistered (see epoll_reactor::deregister_descriptor, which is in turn called from reactive_socket_service_base::destroy/close). This means that your program has closed the socket or destroyed the socket object. </p> <p> Most likely you have a threading issue in your program where you close a socket from one thread while simultaneously starting another async operation on the same socket from another thread. If you are sure this is not the case, please attach a small, complete program that exhibits the problem. Thanks. </p> </blockquote> <p> In my case, the crash is due to two threads simultaneously closing the socket. can you make the socket close or shutdown function thread-safe, just as Fredrik Jansson suggested? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 30 Jan 2017 15:59:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7611#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7611#comment:4" title="Comment 4">jyu@…</a>: </p> <blockquote class="citation"> <p> In my case, the crash is due to two threads simultaneously closing the socket. can you make the socket close or shutdown function thread-safe, just as Fredrik Jansson suggested? </p> </blockquote> <p> You have a threading issue that's even worse than that of the original poster. And it's your all your own fault. </p> <p> Here's how you can solve it: Use a mutex, such that you do NOT have 2 threads messing with the socket at the same time. (Within the protected region, you could find out if the socket-descriptor is already closed, by using something like descriptor.is_open() , see <a href="http://www.boost.org/doc/libs/1_63_0/doc/html/boost_asio/reference.html#boost_asio.reference.posix__basic_descriptor.is_open">http://www.boost.org/doc/libs/1_63_0/doc/html/boost_asio/reference.html#boost_asio.reference.posix__basic_descriptor.is_open</a> ) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 30 Jan 2017 16:45:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7611#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:6</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7611#comment:5" title="Comment 5">anonymous</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7611#comment:4" title="Comment 4">jyu@…</a>: </p> <blockquote class="citation"> <p> In my case, the crash is due to two threads simultaneously closing the socket. can you make the socket close or shutdown function thread-safe, just as Fredrik Jansson suggested? </p> </blockquote> <p> You have a threading issue that's even worse than that of the original poster. And it's your all your own fault. </p> <p> Here's how you can solve it: Use a mutex, such that you do NOT have 2 threads messing with the socket at the same time. (Within the protected region, you could find out if the socket-descriptor is already closed, by using something like descriptor.is_open() , see <a href="http://www.boost.org/doc/libs/1_63_0/doc/html/boost_asio/reference.html#boost_asio.reference.posix__basic_descriptor.is_open">http://www.boost.org/doc/libs/1_63_0/doc/html/boost_asio/reference.html#boost_asio.reference.posix__basic_descriptor.is_open</a> ) </p> </blockquote> <p> I ended up doing compare-and-swap on a flag to make sure the close-socket is called only once. </p> <p> Just wondering that the asio close-socket function may be thread-safe by using the compare-and-swap on that crashing pointer. </p> <p> In my app, only those thread-safe asio socket functions have been used concurrently. I did not realized that the asio close-socket function is an exception. My bad, I did not read the doc carefully. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 13 Jun 2017 19:28:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7611#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:7</guid> <description> <p> I am running into a similar issue (using asio http server) </p> <p> Thread 1 (the main thread) segfaulting in the same spot as the OP while trying to shutdown the server. </p> <p> <a class="missing ticket">#0</a> 0x00000000005a6667 in boost::asio::detail::epoll_reactor::deregister_descriptor (this=0x979c90, descriptor=41, descriptor_data=@0x7fffe4003e68: 0x0, closing=false) at /usr/include/boost/asio/detail/impl/epoll_reactor.ipp:309 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> 0x000000000066068e in boost::asio::detail::reactive_socket_service_base::close (this=0x979e18, impl=..., ec=...) at /usr/include/boost/asio/detail/impl/reactive_socket_service_base.ipp:104 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a> 0x000000000066e1b2 in boost::asio::stream_socket_service&lt;boost::asio::ip::tcp&gt;::close (this=0x979df0, impl=..., ec=...) at /usr/include/boost/asio/stream_socket_service.hpp:170 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3" title="#3: Bugs: automatic conversion and overload proble (closed: fixed)">#3</a> 0x000000000066da0a in boost::asio::basic_socket&lt;boost::asio::ip::tcp, boost::asio::stream_socket_service&lt;boost::asio::ip::tcp&gt; &gt;::close (this=0x7fffe4003e60) at /usr/include/boost/asio/basic_socket.hpp:356 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4" title="#4: Bugs: any_ptr in any library documentation? (closed: Fixed)">#4</a> 0x000000000066af48 in http::server::connection::stop (this=0x7fffe4003e50) at src/main/include/asio_http/connection.cc:35 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5" title="#5: Bugs: shared_ptr and self-owning objects (closed: Fixed)">#5</a> 0x00000000006693b3 in http::server::connection_manager::stop_all (this=0x978560) at src/main/include/asio_http/connection_manager.cc:35 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6" title="#6: Bugs: tie in utility.hpp and tuple.hpp clash. (closed: Duplicate)">#6</a> 0x000000000065a24e in http::server::server::stop (this=0x978510) at src/main/include/asio_http/server.cc:104 </p> <p> Thread 2 (detached thread) started from thread 1 earlier in the application, waiting for thread 3 to return. Thread 3 (detached thread) started from thread 2, running server.run() </p> <p> <a class="missing ticket">#0</a> <span class="underline">lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> 0x00007ffff7bc3dbd in </span>GI<span class="underline">_pthread_mutex_lock (mutex=0x7fffe4003d68) at ../nptl/pthread_mutex_lock.c:80 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a> 0x00000000005a5dea in boost::asio::detail::posix_mutex::lock (this=0x7fffe4003d68) at /usr/include/boost/asio/detail/posix_mutex.hpp:52 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3" title="#3: Bugs: automatic conversion and overload proble (closed: fixed)">#3</a> 0x000000000065e9b7 in boost::asio::detail::epoll_reactor::descriptor_state::perform_io (this=0x7fffe4003d40, events=1) at /usr/include/boost/asio/detail/impl/epoll_reactor.ipp:610 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4" title="#4: Bugs: any_ptr in any library documentation? (closed: Fixed)">#4</a> 0x000000000065eb57 in boost::asio::detail::epoll_reactor::descriptor_state::do_complete (owner=0x976050, base=0x7fffe4003d40, ec=..., bytes_transferred=1) at /usr/include/boost/asio/detail/impl/epoll_reactor.ipp:649 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5" title="#5: Bugs: shared_ptr and self-owning objects (closed: Fixed)">#5</a> 0x000000000065ce0e in boost::asio::detail::task_io_service_operation::complete (this=0x7fffe4003d40, owner=..., ec=..., bytes_transferred=1) at /usr/include/boost/asio/detail/task_io_service_operation.hpp:38 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6" title="#6: Bugs: tie in utility.hpp and tuple.hpp clash. (closed: Duplicate)">#6</a> 0x000000000065f78f in boost::asio::detail::task_io_service::do_run_one (this=0x976050, lock=..., this_thread=..., ec=...) at /usr/include/boost/asio/detail/impl/task_io_service.ipp:372 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7" title="#7: Bugs: g++ 2.96 requires NO_STRINGSTREAM (closed: Fixed)">#7</a> 0x000000000065f1c9 in boost::asio::detail::task_io_service::run (this=0x976050, ec=...) at /usr/include/boost/asio/detail/impl/task_io_service.ipp:149 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8" title="#8: Bugs: prop in undirected graph + out_edges (closed: Works For Me)">#8</a> 0x000000000065f9e2 in boost::asio::io_service::run (this=0x978510) at /usr/include/boost/asio/impl/io_service.ipp:59 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9" title="#9: Bugs: config_info ambiguity error (closed: Invalid)">#9</a> 0x0000000000659ff0 in http::server::server::run (this=0x978510) at src/main/include/asio_http/server.cc:64 server thread and some other threads and waits for them to return. </span></p> <p> Although thread 3 can also be in other parts of the code when this occurs. </p> <p> <a class="missing ticket">#0</a> 0x00007ffff5edbe23 in epoll_wait () at ../sysdeps/unix/syscall-template.S:84 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> 0x000000000065e319 in boost::asio::detail::epoll_reactor::run (this=0x979c90, block=true, ops=...) at /usr/include/boost/asio/detail/impl/epoll_reactor.ipp:392 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a> 0x000000000065f70b in boost::asio::detail::task_io_service::do_run_one (this=0x976050, lock=..., this_thread=..., ec=...) at /usr/include/boost/asio/detail/impl/task_io_service.ipp:356 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3" title="#3: Bugs: automatic conversion and overload proble (closed: fixed)">#3</a> 0x000000000065f1c9 in boost::asio::detail::task_io_service::run (this=0x976050, ec=...) at /usr/include/boost/asio/detail/impl/task_io_service.ipp:149 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4" title="#4: Bugs: any_ptr in any library documentation? (closed: Fixed)">#4</a> 0x000000000065f9e2 in boost::asio::io_service::run (this=0x978510) at /usr/include/boost/asio/impl/io_service.ipp:59 <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5" title="#5: Bugs: shared_ptr and self-owning objects (closed: Fixed)">#5</a> 0x0000000000659ff0 in http::server::server::run (this=0x978510) at src/main/include/asio_http/server.cc:64 </p> <p> This occurs after the server has been running for some time (serving data without issue), and only during the shutdown sequence. I have done no modifications to the asio http server code and am using libcurl to do all of the transactions (which are done by thread 1 before the shutdown is called.) Making the changes in the OP does seem to resolve the issue. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 13 Jun 2017 19:43:15 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/7611#comment:8 https://svn.boost.org/trac10/ticket/7611#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">invalid</span> </li> </ul> Ticket bronf Thu, 28 Sep 2017 14:02:22 GMT attachment set https://svn.boost.org/trac10/ticket/7611 https://svn.boost.org/trac10/ticket/7611 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">asio_bug.cpp</span> </li> </ul> <p> minimal example to reproduce the bug </p> Ticket bronf Thu, 28 Sep 2017 14:10:03 GMT attachment set https://svn.boost.org/trac10/ticket/7611 https://svn.boost.org/trac10/ticket/7611 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">gdb.log</span> </li> </ul> <p> gdb log with backtrace </p> Ticket bronf Thu, 28 Sep 2017 14:17:13 GMT <link>https://svn.boost.org/trac10/ticket/7611#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:9</guid> <description> <p> I encountered the same bug and made a minimal example attached to this page to reproduce the bug (tested with 1.65.1). See also the gdb output, I kept the core if you would like me to extract some more information. </p> <p> My program starts a server which just waits with the connected socket while the client writes a large amount of data. Because the server does not read, the write operation is stopped and the timer expires and cancels the write operation by closing the client socket. (This is just a test program, not a real program). </p> <p> Apparently, in rare situations, closing the socket while in async_write gives a segmentation fault because of the dereferencement of a nullptr (descriptor_data). </p> <p> boost/include/boost/asio/detail/impl/epoll_reactor.ipp:230 230 if (descriptor_data-&gt;shutdown_) (gdb) print descriptor_data $1 = (boost::asio::detail::epoll_reactor::per_descriptor_data &amp;) @0x64de48: 0x0 </p> <p> Because the bug appears very rarely, this is what I do to make it happen and stop in gdb: while gdb -ex run -ex quit ./asio_bug ; do true; done </p> <p> In parallel, I try to load the computer with a lot of things (not sure if this helps to make the bug appear). </p> <p> Tested on linux 64 bits with gcc 7.2.0 and boost 1.65.1. </p> </description> <category>Ticket</category> </item> <item> <author>ddsherstennikov@…</author> <pubDate>Wed, 25 Apr 2018 16:15:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7611#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:10</guid> <description> <p> Any progress since then? </p> </description> <category>Ticket</category> </item> <item> <author>ddsherstennikov@…</author> <pubDate>Wed, 25 Apr 2018 16:19:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7611#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:11</guid> <description> <p> boost 1.65.0 </p> <p> linux 64 </p> <p> gcc 7.2.0 </p> </description> <category>Ticket</category> </item> <item> <author>Eduardo Iglesias <7i77an@…></author> <pubDate>Thu, 17 May 2018 14:42:44 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7611#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:12</guid> <description> <p> Same situation with boost 1.59 version. </p> <p> <a class="missing ticket">#0</a> 0x000000000057ecef in boost::asio::detail::epoll_reactor::start_op (this=0x272c050, op_type=0, descriptor=852, descriptor_data=@0x7f536c000e68: 0x0, op=0x7f54c8005f80, is_continuation=true, </p> <blockquote> <p> allow_speculative=true) at /usr/local/include/boost-1_59/boost/asio/detail/impl/epoll_reactor.ipp:219 </p> </blockquote> <p> As additional information, the fall started to happen with Debian Jessie. In debian Squeeze, the error does not appear. </p> </description> <category>Ticket</category> </item> <item> <author>Eduardo Iglesias <7i77an@…></author> <pubDate>Thu, 17 May 2018 15:35:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7611#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:13</guid> <description> <p> I correct, with boost 1.44 version into debian Squeeze, the error does not appear. </p> </description> <category>Ticket</category> </item> <item> <author>abdurrahim.cakar@…</author> <pubDate>Sat, 07 Jul 2018 09:52:30 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7611#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:14</guid> <description> <p> Why C++ sucks so bad version 1.67 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 31 Jul 2018 12:54:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7611#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7611#comment:15</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7611#comment:2" title="Comment 2">chris_kohlhoff</a>: </p> <blockquote class="citation"> <p> The descriptor_data variable is only set to NULL when the corresponding socket is deregistered (see epoll_reactor::deregister_descriptor, which is in turn called from reactive_socket_service_base::destroy/close). This means that your program has closed the socket or destroyed the socket object. </p> <p> Most likely you have a threading issue in your program where you close a socket from one thread while simultaneously starting another async operation on the same socket from another thread. If you are sure this is not the case, please attach a small, complete program that exhibits the problem. Thanks. </p> </blockquote> <p> Hi all, I'm using boost asio 1.67.0 in a quite big application. It is a webrtc server that uses both tcp and udp sockets to forward data among users. </p> <p> The server can run both on windows or linux. </p> <p> And I have the same issue reported above on linux only. On windows it works fine. </p> <p> It is difficult to reproduce, but I found a scenario that works using valgrind. </p> <p> The threading model I'm using is one io_service, multiple threads. </p> <p> The behavior of the application in the point near the crash is the following: when the tcp socket of the user disconnects, then the server closes the udp socket and finalizes the session for that user. </p> <p> The crash happens (sometimes) closing the udp socket while it is reading/writing. </p> <p> Following you suggestion I wrapped all async operations of read/write/close in the same strand (one per udp socket) and magically it stopped crashing. </p> <p> Before this, the strand was used only to serialize the write operations and avoid unordered transmission of packets. Because the read_async is called after the processing of the previous data chunk. </p> <p> I checked the release notes of the previous versions of boost and it seems that the problem has been fixed into 1.65.0: Fixed a race condition in the Linux epoll backend, which may occur when a socket or descriptor is closed while another thread is blocked on epoll. </p> <p> But it is not. </p> <p> For what I understood about asio, it should be possible to read and write on the same socket from different threads without any problem. But if the close requires serialization, then all read/ write operations must be wrapped by a strand. And it will affect the performance (a bit). </p> <p> Is this a bug inside the epoll/linux implementation of asio sockets or is it the correct way of working and it must be managed by the application? </p> <p> Thank you, let me know if I can do something to help to solve. </p> <p> Emanuele </p> </description> <category>Ticket</category> </item> </channel> </rss>