Boost C++ Libraries: Ticket #5763: Segmentation fault in ASIO signal handler https://svn.boost.org/trac10/ticket/5763 <p> Hello! </p> <p> I am using boost asio 1.47.0 to system signal handler. If using compiler Intel Composer XE 12.0.1 and optimization level greater -01 segmentation fault occurs in file boost/asio/detail/signal_handler.hpp:67. In code line: </p> <pre class="wiki">boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); </pre><p> If insert before this line "sleep(0)" or write to stdout ASIO work normal. If using GCC 4.1.2, 4.3.4, 4.5.0, 4.6.1(MinGW) and Intel C++ 11.1 code work normal. </p> <p> I noticed that the ICC and GCC use different versions of fenced_block and replaced gcc_x86_fenced_block to gcc_sync_fenced_block in ICC then error is gone. </p> <p> Function <span class="underline">sync_lock_test_and_set is available in the ICC since version 11.0, I wrote the appropriate patch. </span></p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5763 Trac 1.4.3 Vladislav <phprus@…> Mon, 08 Aug 2011 07:50:43 GMT attachment set https://svn.boost.org/trac10/ticket/5763 https://svn.boost.org/trac10/ticket/5763 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_1_47_0-intel-segfault-in-asio-signal.diff</span> </li> </ul> Ticket Vladislav <phprus@…> Mon, 08 Aug 2011 08:00:39 GMT <link>https://svn.boost.org/trac10/ticket/5763#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5763#comment:1</guid> <description> <p> Sorry. Typo in compiler version. Compiler Intel Composer XE 12.0.4 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Mon, 08 Aug 2011 08:31:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5763#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5763#comment:2</guid> <description> <p> Thank you for providing a patch. However, without a test case, I cannot confirm that this is the correct fix. Can you please supply a small test program that can be used to reproduce the error. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Mon, 08 Aug 2011 08:32:12 GMT</pubDate> <title>severity, milestone changed https://svn.boost.org/trac10/ticket/5763#comment:3 https://svn.boost.org/trac10/ticket/5763#comment:3 <ul> <li><strong>severity</strong> <span class="trac-field-old">Regression</span> → <span class="trac-field-new">Problem</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.48.0</span> → <span class="trac-field-new">To Be Determined</span> </li> </ul> Ticket Vladislav <phprus@…> Mon, 08 Aug 2011 08:49:27 GMT <link>https://svn.boost.org/trac10/ticket/5763#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5763#comment:4</guid> <description> <p> Test case: <a href="http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/examples.html">http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/examples.html</a> "HTTP Server" Segmentation fault on recived SIGINT. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Mon, 08 Aug 2011 09:54:44 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5763#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5763#comment:5</guid> <description> <p> Please also specify the target platform, architecture (32 or 64 bit) and compiler command line used. </p> </description> <category>Ticket</category> </item> <item> <author>Vladislav <phprus@…></author> <pubDate>Mon, 08 Aug 2011 11:00:30 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5763#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5763#comment:6</guid> <description> <p> Problem platform: openSUSE 11.3 x86 (32 bit) </p> <p> Boost built by system gcc 4.5.0, application is built by Intel 12.0.4 </p> <p> Command line: </p> <pre class="wiki">icpc -O3 -g -lboost_thread -lboost_system *.cpp </pre><p> or </p> <pre class="wiki">icpc -gxx-name=g++-4.3 -O3 -g -lboost_thread -lboost_system *.cpp </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Mon, 08 Aug 2011 13:23:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5763#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5763#comment:7</guid> <description> <p> I was able to reproduce the issue, and I believe the correct fix is to apply the following change to asio/include/asio/detail/gcc_x86_fenced_block.hpp: </p> <pre class="wiki">@@ -43,8 +43,12 @@ public: private: static int barrier() { - int r = 0; - __asm__ __volatile__ ("xchgl %%eax, %0" : "=m" (r) : : "memory", "cc"); + int r = 0, m = 1; + __asm__ __volatile__ ( + "xchgl %0, %1" : + "=r"(r), "=m"(m) : + "0"(1), "m"(m) : + "memory", "cc"); return r; } }; </pre><p> Can you please try this change and let me know if it also corrects the issue for you. </p> <p> Note that using the gcc_sync_fenced_block class does improve performance slightly, so I will also look to include your patch in the near future. </p> </description> <category>Ticket</category> </item> <item> <author>Vladislav <phprus@…></author> <pubDate>Mon, 08 Aug 2011 13:40:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5763#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5763#comment:8</guid> <description> <p> Your patch fixes a bug. </p> </description> <category>Ticket</category> </item> <item> <author>Vladislav <phprus@…></author> <pubDate>Wed, 17 Aug 2011 19:14:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5763#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5763#comment:9</guid> <description> <p> Tell please how there are affairs with bug fix? </p> </description> <category>Ticket</category> </item> <item> <author>Vladislav <phprus@…></author> <pubDate>Wed, 07 Sep 2011 09:32:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5763#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5763#comment:10</guid> <description> <p> Tell please how there are affairs with bug fix? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Sat, 08 Oct 2011 21:31:29 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5763#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5763#comment:11</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/74822" title="Fix crash due to gcc_x86_fenced_block that shows up when using the ...">[74822]</a>) Fix crash due to gcc_x86_fenced_block that shows up when using the Intel C++ compiler. Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5763" title="#5763: Patches: Segmentation fault in ASIO signal handler (closed: fixed)">#5763</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Sun, 09 Oct 2011 22:00:09 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5763#comment:12 https://svn.boost.org/trac10/ticket/5763#comment:12 <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">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/74863" title="Merge from trunk... Fix compile error in regex overload of ...">[74863]</a>) Merge from trunk... </p> <p> Fix compile error in regex overload of async_read_until.hpp. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5688" title="#5688: Bugs: boost::asio::async_read_until with boost::regex compilation error (closed: fixed)">#5688</a> </p> <p> Explicitly specify the signal() function from the global namespace. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5722" title="#5722: Bugs: Compilation error when boost/signals.hpp is included before asio.hpp (closed: fixed)">#5722</a> </p> <p> Don't read the clock unless the heap is non-empty. </p> <p> Change the SSL buffers sizes so that they're large enough to hold a complete TLS record. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5854" title="#5854: Bugs: asio::ssl::stream holds last 16K until shutdown IF last buffer is on ... (closed: fixed)">#5854</a> </p> <p> Make sure the synchronous null_buffers operations obey the user's non_blocking setting. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5756" title="#5756: Bugs: read_some() with null_buffers blocks in non-blocking mode (closed: fixed)">#5756</a> </p> <p> Set size of select fd_set at runtime when using Windows. </p> <p> Disable warning due to const qualifier being applied to function type. </p> <p> Fix crash due to gcc_x86_fenced_block that shows up when using the Intel C++ compiler. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5763" title="#5763: Patches: Segmentation fault in ASIO signal handler (closed: fixed)">#5763</a> </p> <p> Specialise operations for buffer sequences that are arrays of exactly two buffers. </p> <p> Initialise all OpenSSL algorithms. </p> <p> Fix error mapping when session is gracefully shut down. </p> <p> Various performance improvements: </p> <ul><li>Split the task_io_service's run and poll code. </li></ul><ul><li>Use thread-local operation queues in single-threaded use cases (i.e. concurrency_hint is 1) to eliminate a lock/unlock pair. </li></ul><ul><li>Only fence block exit when a handler is being run directly out of the io_service. </li></ul><ul><li>Prefer x86 mfence-based fenced block when available. </li></ul><ul><li>Use a plain ol' long for the atomic_count when all thread support is disabled. </li></ul><ul><li>Allow some epoll_reactor speculative operations to be performed without holding the lock. </li></ul><ul><li>Improve locality of reference by performing an epoll_reactor's I/O operation immediately before the corresponding handler is called. This also improves scalability across CPUs when multiple threads are running the io_service. </li></ul><ul><li>Pass same error_code variable through to each operation's complete() function. </li></ul><ul><li>Optimise creation of and access to the io_service implementation. </li></ul><p> Remove unused state in HTTP server examples. </p> <p> Add latency test programs. </p> Ticket