Boost C++ Libraries: Ticket #11923: Boost Log backends fail silently on Ubuntu https://svn.boost.org/trac10/ticket/11923 <p> When compiled on Ubuntu, a test program using the global logger with custom sink backends fails to run properly. It produces no output to the console or to a file (it should do both). It does not produce any error messages or warnings during either the compilation, nor the run time. I believe this is caused by a failure on the part of the library to properly add new sinks. My believe is founded on the observation that: (1) the code works fine on another machine, (2) the dedicated thread for the asynchronous_sink can be observed, (3) when no new sinks are added the logger works fine (in default mode). </p> <p> Includes: sample code, build scripts, and testing notes. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11923 Trac 1.4.3 lylemoffitt@… Tue, 19 Jan 2016 04:45:37 GMT attachment set https://svn.boost.org/trac10/ticket/11923 https://svn.boost.org/trac10/ticket/11923 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">logging_test.zip</span> </li> </ul> <p> Zip'd files of sample code, with notes, and build scripts </p> Ticket lylemoffitt@… Tue, 19 Jan 2016 17:03:21 GMT <link>https://svn.boost.org/trac10/ticket/11923#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11923#comment:1</guid> <description> <p> Correction: Boost version on Linux is <strong>v1.54</strong> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Wed, 20 Jan 2016 08:51:44 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11923#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11923#comment:2</guid> <description> <p> Could you please test it with the latest Boost version (from git develop or at least 1.60)? </p> </description> <category>Ticket</category> </item> <item> <author>lylemoffitt@…</author> <pubDate>Wed, 20 Jan 2016 22:14:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11923#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11923#comment:3</guid> <description> <p> Tried it with the instructions from <a href="http://www.boost.org/doc/libs/1_60_0/more/getting_started/unix-variants.html">here</a>, but dead-ended in some 'undefined reference' errors. </p> <pre class="wiki">/usr/local/include/boost/log/sinks/unbounded_fifo_queue.hpp:78: error: undefined reference to 'boost::log::v2_mt_posix::aux::futex_based_event::futex_based_event()' /usr/local/include/boost/log/sinks/unbounded_fifo_queue.hpp:56: error: undefined reference to 'boost::log::v2_mt_posix::aux::futex_based_event::~futex_based_event()' /usr/local/include/boost/log/sinks/unbounded_fifo_queue.hpp:129: error: undefined reference to 'boost::log::v2_mt_posix::aux::futex_based_event::set_signalled()' /usr/local/include/boost/log/sinks/unbounded_fifo_queue.hpp:84: error: undefined reference to 'boost::log::v2_mt_posix::aux::futex_based_event::set_signalled()' /usr/local/include/boost/log/sinks/unbounded_fifo_queue.hpp:117: error: undefined reference to 'boost::log::v2_mt_posix::aux::futex_based_event::wait()' /usr/local/include/boost/log/sources/global_logger_storage.hpp:120: error: undefined reference to 'boost::log::v2_mt_posix::sources::aux::global_storage::get_or_init(boost::typeindex::stl_type_index, boost::shared_ptr&lt;boost::log::v2_mt_posix::sources::aux::logger_holder_base&gt; (*)())' /usr/local/include/boost/log/sources/global_logger_storage.hpp:136: error: undefined reference to 'boost::log::v2_mt_posix::sources::aux::throw_odr_violation(boost::typeindex::stl_type_index, boost::typeindex::stl_type_index, boost::log::v2_mt_posix::sources::aux::logger_holder_base const&amp;)' </pre><p> It's possible I messed up the installation. Is there a dpkg repo I can try installing from? </p> <p> Whatever the solution, it needs to work on Ubuntu 14.04 LTS, since that's the target platform for my codebase. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 20 Jan 2016 23:03:00 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11923#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11923#comment:4</guid> <description> <p> Ok. Got it all sorted out. Had to reset the VM, uninstall all the old boost libs from <code>dpkg</code>, reinstall v1.60 *and* run <code>ldconfig</code> (forgot to do that before). Now it compiles and runs. Same result as before, bupkis. </p> <p> And btw, this is all compiled with GCC. So there's no incompatibility introduced from there. </p> <p> Here's confirmation from <code>ldd</code> that it was all linked correctly: </p> <pre class="wiki">ldd ./log_test linux-vdso.so.1 =&gt; (0x00007ffd8ddc4000) libboost_log.so.1.60.0 =&gt; /usr/local/lib/libboost_log.so.1.60.0 (0x00007fbcc9a98000) libboost_thread.so.1.60.0 =&gt; /usr/local/lib/libboost_thread.so.1.60.0 (0x00007fbcc9876000) libboost_system.so.1.60.0 =&gt; /usr/local/lib/libboost_system.so.1.60.0 (0x00007fbcc9672000) libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fbcc9454000) libunwind.so.8 =&gt; /usr/lib/x86_64-linux-gnu/libunwind.so.8 (0x00007fbcc9239000) libstdc++.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fbcc8f35000) libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbcc8b70000) libboost_filesystem.so.1.60.0 =&gt; /usr/local/lib/libboost_filesystem.so.1.60.0 (0x00007fbcc8957000) librt.so.1 =&gt; /lib/x86_64-linux-gnu/librt.so.1 (0x00007fbcc874f000) libgcc_s.so.1 =&gt; /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fbcc8539000) /lib64/ld-linux-x86-64.so.2 (0x00007fbcc9d44000) liblzma.so.5 =&gt; /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fbcc8317000) libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbcc8011000) libdl.so.2 =&gt; /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fbcc7e0d000) </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Sat, 23 Jan 2016 12:18:59 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/11923#comment:5 https://svn.boost.org/trac10/ticket/11923#comment:5 <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 attached test produces both console and file output on my system. I didn't dig into the test code too much, but I didn't find you calling <code>flush()</code> on the core or sink before exiting the process. Since you're using the asynchronous sink frontend, it is possible that some of the log records are left in the queue unprocessed when the test terminates. I suppose this may be the reason why you observe different results on different machines. </p> Ticket Lyle Moffitt <lylemoffitt@…> Mon, 25 Jan 2016 21:23:22 GMT <link>https://svn.boost.org/trac10/ticket/11923#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11923#comment:6</guid> <description> <ol><li> What system are you testing on? Is is Ubuntu 14.04? This problem is likely specific to at the very least that distro. </li><li> I don't think you looked at the source code at all.. Both sinks are set to <code>auto_flush=true</code>. </li><li> If the problem were that <code>"some of the log records are left in the queue unprocessed when the test terminates"</code>, then it would be easy to prove it so. Here are some ways you could do that: <ol class="loweralpha"><li>You could simply add a<code>log_data::file_sink-&gt;flush()</code> command before exiting <code>main()</code>. </li><li>You could remove the filter step to prevent the queue from being blocked. </li><li>You could remove the async sink from the logger and just use the synchronous terminal sink, which would not be blocked. </li></ol></li><li> Here are some reasons why I don't think your hypotheses is correct: <ol class="loweralpha"><li>The <code>test_file_backend</code> is setup to create a file and write a header to it before <em>any</em> logging is done. </li><li>I tried calling <code>flush()</code> for both sinks before exiting <code>main()</code>. If the messages were stuck in the queue somehow, then this would have prevented the program from exiting at all, since both methods a defined to block until the queue is empty. </li><li>I am in fact using 2 sinks (async'd file and sync'd terminal). Your explanation completely misses the latter. </li></ol></li></ol><p> TL;DR: Your explanation is just plain wrong. </p> <hr /> <p> I took a lot of time to make this as simple an example as possible while still retaining the essence of the problem. I took pains to document and format a bug report to help you out. The fact that you barely looked at the code and then gave me a half-assed answer is frankly insulting. If you aren't going to take this seriously, please pass this bug to someone who will. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Tue, 26 Jan 2016 08:48:02 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11923#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11923#comment:7</guid> <description> <ol><li>Kubuntu 15.10. </li><li><code>auto_flush</code> has no effect on the sink frontend, where the queueing happens. </li><li>I'm not going to prove anything. You're the one who can reproduce the problem, so you're going to have to try the solution. Or not, and live on with the problem. </li><li>There's no <code>test_file_backend</code>. <code>text_file_backend</code> only creates the file on the first record it receives, so the file will not appear if no records reach the backend. </li></ol><p> It's true I didn't notice that the console sink is synchronous. The output would have appeared at least on the console, so since you're not getting it the problem is elsewhere. </p> <p> Upon further inspection I noticed you're using <code>std::regex</code> in your filter. If you're using gcc 4.8, the official one in 14.04, then it is broken and may be the reason why all records are filtered away (<code>std::regex</code> was actually implemented in <a class="ext-link" href="https://gcc.gnu.org/gcc-4.9/changes.html"><span class="icon">​</span>4.9</a>). Try switching to <code>boost::regex</code>. </p> <p> If that doesn't help, debug your code. See if your filter works. See if records reach the sinks. See if any exceptions are thrown. Step through the processing of a log record in the debugger. </p> <hr /> <p> Suck up your emotions and deal with the problem. You're only one able to reproduce it, so it's highly likely the source is on your end. I'm not paid to read your whining and debug your code, and my time is limited. I suggested a possible solution; it may be wrong but that's why you are here - to try it out and provide more info. That's how solving the problem works. Also, I'm the only maintainer of Boost.Log, so you're unlikely to get help elsewhere. </p> </description> <category>Ticket</category> </item> <item> <author>Lyle Moffitt <lylemoffitt@…></author> <pubDate>Wed, 27 Jan 2016 05:34:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11923#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11923#comment:8</guid> <description> <p> Thank you for taking the time to look at my code. Really. That alone made all the difference. </p> <p> It turns out that you were spot on about <code>std::regex</code> being the the source of the problem. Simply commenting out the lines that use it is enough to produce the desired behavior. It works on both boost v1.54 and boost v1.60. </p> <p> The remaining point of curiosity is why this doesn't work with clang 3.4 (and libc++), which supposedly have support for <code>std::regex</code>... (But that's not really important.) </p> <p> Thanks for the suggestion on <code>boost::regex</code>; it was an easy, drop-in replacement. </p> <hr /> <p> Thank you for you time and help. </p> </description> <category>Ticket</category> </item> </channel> </rss>