Boost C++ Libraries: Ticket #13632: boost::function operator== is bugged on FreeBSD 11.2 https://svn.boost.org/trac10/ticket/13632 <p> The Passenger application server is a C++ application and uses Boost. Our FreeBSD 11.2 users ran into a crash bug: <a class="ext-link" href="https://github.com/phusion/passenger/issues/2097"><span class="icon">​</span>https://github.com/phusion/passenger/issues/2097</a> </p> <p> Upon further investigation, it turns out that the underlying problem is boost::function operator==. The following test program... </p> <pre class="wiki">boost::function&lt;void ()&gt; f; printf("is null: %d\n", f == NULL); </pre><p> ...prints 1 on macOS (as it should) and 0 on FreeBSD 11.2. I haven't tested this small test program on FreeBSD 11.1, but users reported that Passenger worked fine on FreeBSD 11.1 so the problem likely did not exist there. </p> <p> Digger deeper, on FreeBSD the == operator calls this function (in boost/function/function_base.hpp): </p> <pre class="wiki"># if !(defined(__GNUC__) &amp;&amp; __GNUC__ == 3 &amp;&amp; __GNUC_MINOR__ &lt;= 3) // Comparisons between boost::function objects and arbitrary function // objects. GCC 3.3 and before has an obnoxious bug that prevents this // from working. template&lt;typename Functor&gt; BOOST_FUNCTION_ENABLE_IF_NOT_INTEGRAL(Functor, bool) operator==(const function_base&amp; f, Functor g) { if (const Functor* fp = f.template target&lt;Functor&gt;()) return function_equal(*fp, g); else return false; } </pre><p> ...and returns false (the else branch). </p> <p> While on macOS it calls this function: </p> <pre class="wiki">inline bool operator!=(const function_base&amp; f, detail::function::useless_clear_type*) { return !f.empty(); } </pre><p> Just looking at the #if there already gives me the feeling that it is not right. Boost is trying to work around a GCC 3 bug but it wrongly detects Clang 6.0.0 as GCC 3. </p> <p> This bug has been confirmed on both Boost 1.64 and Boost 1.67. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13632 Trac 1.4.3 VVD Wed, 11 Jul 2018 18:52:36 GMT <link>https://svn.boost.org/trac10/ticket/13632#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13632#comment:1</guid> <description> <p> FreeBSD 11.1 have clang 4.0.0, but FreeBSD 11.2 have clang 6.0.0. Passenger compiled with GCC 6.4.0 from ports on FreeBSD 11.2 work fine. </p> <p> Probably boost don't support clang 6.0.0. </p> <p> Bug reports in other trackers with more information: <a class="ext-link" href="https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229392"><span class="icon">​</span>https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229392</a> <a class="ext-link" href="https://github.com/phusion/passenger/issues/2097"><span class="icon">​</span>https://github.com/phusion/passenger/issues/2097</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sun, 15 Jul 2018 16:28:36 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13632#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13632#comment:2</guid> <description> <p> Important update. It was discovered that FreeBSD 11.2, as well as recent versions of OpenBSD, promote <code>NULL</code> to <code>nullptr</code>. Comparing an empty boost::function with 0 results in true, but comparing it with nullptr results in false: </p> <pre class="wiki">boost::function&lt;void ()&gt; f; printf("is nullptr: %d\n", f == nullptr); printf("is 0: %d\n", f == 0); </pre><p> This prints 0 and 1, respectively. </p> <p> Is this behavior intentional? Are we supposed to be able to compare boost::function with nullptr? Intuitively I would expect <code>== 0</code> and <code>== nullptr</code> to behave the same. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>VVD</dc:creator> <pubDate>Sun, 22 Jul 2018 01:00:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13632#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13632#comment:3</guid> <description> <p> You can close this bugreport. Detailed explanation is here: <a class="ext-link" href="https://www.joyfulbikeshedding.com/blog/2018-07-17-do-not-compare-boost-function-with-null.html"><span class="icon">​</span>https://www.joyfulbikeshedding.com/blog/2018-07-17-do-not-compare-boost-function-with-null.html</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>