Boost C++ Libraries: Ticket #8443: Header file inclusion order may cause crashes https://svn.boost.org/trac10/ticket/8443 <p> pthread/mutex.hpp and pthread/recursive_mutex.hpp both attempt to define the macro BOOST_PTHREAD_HAS_TIMEDLOCK. They each have different conditions for when to define it, which results in different cpp files thinking certain objects are different sizes, and it (hopefully) crashes. </p> <p> While it would be good to provide logic for defining the symbol in one place (mutex.hpp was most recently updated for <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3639" title="#3639: Bugs: Boost.Thread doesn't build with Sun-5.9 on Linux (closed: fixed)">#3639</a>), I believe that both conditions are wrong: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#ifdef _POSIX_TIMEOUTS</span> <span class="cp">#if _POSIX_TIMEOUTS &gt;= 0</span> <span class="cp">#define BOOST_PTHREAD_HAS_TIMEDLOCK</span> <span class="cp">#endif</span> <span class="cp">#endif</span> </pre></div></div><p> and </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#ifdef _POSIX_TIMEOUTS</span> <span class="cp">#if _POSIX_TIMEOUTS &gt;= 0 &amp;&amp; _POSIX_C_SOURCE&gt;=200112L</span> <span class="cp">#define BOOST_PTHREAD_HAS_TIMEDLOCK</span> <span class="cp">#endif</span> <span class="cp">#endif</span> </pre></div></div><p> I think using _POSIX_C_SOURCE is not right. On our platform (solaris variant), _POSIX_C_SOURCE == 199506L, but _POSIX_TIMEOUTS == 200112L and pthread_mutex_timedlock is available. </p> <p> Thus, I suggest using the following for both conditions (and hopefully testing the condition in one place): </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#if defined(_POSIX_TIMEOUTS) &amp;&amp; _POSIX_TIMEOUTS &gt;= 200112L</span> <span class="cp">#define BOOST_PTHREAD_HAS_TIMEDLOCK</span> <span class="cp">#endif</span> </pre></div></div><p> This problem is in trunk starting with at least 1.49, and remains in the current version, as well as trunk. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8443 Trac 1.4.3 Nathan Crookston <nathan.crookston+boost@…> Mon, 15 Apr 2013 22:50:17 GMT <link>https://svn.boost.org/trac10/ticket/8443#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8443#comment:1</guid> <description> <p> Here's an example of checking the _POSIX_TIMEOUTS variable as suggested above: <a class="ext-link" href="http://lists.apple.com/archives/unix-porting/2008/Jan/msg00014.html"><span class="icon">​</span>http://lists.apple.com/archives/unix-porting/2008/Jan/msg00014.html</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 17 Apr 2013 04:40:56 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/8443#comment:2 https://svn.boost.org/trac10/ticket/8443#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket viboes Thu, 18 Apr 2013 07:02:33 GMT milestone changed https://svn.boost.org/trac10/ticket/8443#comment:3 https://svn.boost.org/trac10/ticket/8443#comment:3 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.54.0</span> </li> </ul> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/83948" title="Thread: make unnifor definition of BOOST_PTHREAD_HAS_TIMEDLOCK #8443.">[83948]</a>. </p> Ticket Nathan Crookston <nathan.crookston+boost@…> Thu, 18 Apr 2013 15:13:34 GMT <link>https://svn.boost.org/trac10/ticket/8443#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8443#comment:4</guid> <description> <p> Hi Vicente, </p> <p> Thanks for fixing the different conditions to define BOOST_PTHREAD_HAS_TIMEDLOCK. In my note, I mentioned that using _POSIX_C_SOURCE isn't likely the right thing -- using _POSIX_TIMEOUTS should be. </p> <p> Is there a reason to continue to use _POSIX_C_SOURCE? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 18 Apr 2013 16:58:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8443#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8443#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8443#comment:4" title="Comment 4">Nathan Crookston &lt;nathan.crookston+boost@…&gt;</a>: </p> <blockquote class="citation"> <p> Hi Vicente, </p> <p> Thanks for fixing the different conditions to define BOOST_PTHREAD_HAS_TIMEDLOCK. In my note, I mentioned that using _POSIX_C_SOURCE isn't likely the right thing -- using _POSIX_TIMEOUTS should be. </p> <p> Is there a reason to continue to use _POSIX_C_SOURCE? </p> </blockquote> <p> Sorry, I missed this point. I will see if there is no regression with _POSIX_TIMEOUTS. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 18 Apr 2013 21:35:18 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8443#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8443#comment:6</guid> <description> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/83962" title="Thread: make use of _POSIX_TIMEOUTS instead of _POSIX_C_SOURCE on the ...">[83962]</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 21 Apr 2013 07:31:00 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8443#comment:7 https://svn.boost.org/trac10/ticket/8443#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</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/83993" title="Thread: fix #8443.">[83993]</a>) Thread: fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8443" title="#8443: Bugs: Header file inclusion order may cause crashes (closed: fixed)">#8443</a>. </p> Ticket