Boost C++ Libraries: Ticket #1268: xtime_cmp changes to deal with overflow were reverted https://svn.boost.org/trac10/ticket/1268 <p> I'm running into this situation when specifying a very long timeout that winds up using boost::condition::timed_wait with an xtime value set up like so: </p> <p> boost::xtime xt; boost::xtime_get( &amp;xt, boost::TIME_UTC ); xt.sec += std::numeric_limits&lt;uint32_t&gt;::max(); <em> ignore potential overflow, as sec is 64-bit condition.timed_wait( lock, xt ); </em> &lt;- this returns immediately </p> <p> Traced this down to an overflow in xtime_cmp (boost/thread/xtime.hpp) that was fixed in version 1.14 of the file and reverted in version 1.15 of the file (replaced with the pre-1.14 version). </p> <p> This is present in 1.33.1 (version being used on project) and in 1.34.1. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1268 Trac 1.4.3 oseiler@… Fri, 14 Sep 2007 19:43:21 GMT <link>https://svn.boost.org/trac10/ticket/1268#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1268#comment:1</guid> <description> <p> Sorry about formatting; should have previewed. Here's the code fragment: </p> <pre class="wiki">boost::xtime xt; boost::xtime_get( &amp;xt, boost::TIME_UTC ); xt.sec += std::numeric_limits&lt;uint32_t&gt;::max(); // ignore potential overflow, as sec is 64-bit condition.timed_wait( lock, xt ); // &lt;- this returns immediately </pre> </description> <category>Ticket</category> </item> <item> <author>oseiler@…</author> <pubDate>Fri, 14 Sep 2007 19:53:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1268#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1268#comment:2</guid> <description> <p> Not sure what happened here, but everything I say above is wrong, except for the timed_wait behaviour; xtime.hpp didn't get reverted, the correct xtime_cmp is present in 1.33.1 and 1.34.1, and I appear to be unable to drive the web interface to the CVS repository. </p> <p> boost::condition::timed_wait <strong>is</strong> returning immediately in the above situation, but my assessment is completely wrong. </p> </description> <category>Ticket</category> </item> <item> <author>oseiler@…</author> <pubDate>Fri, 14 Sep 2007 20:56:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1268#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1268#comment:3</guid> <description> <p> Working around this seems to indicate some underlying limitation of the boost implementation under Unix (1.33.1 running under SLES 10). By limiting xt.sec to numeric_limits&lt;int&gt;::max(), the timed_wait works correctly: </p> <pre class="wiki">xt.sec += timeout; // timeout == numeric_limits&lt;uint32_t&gt;::max() in this case if ( xt.sec &gt; std::numeric_limits&lt;int&gt;::max() ) xt.sec = std::numeric_limits&lt;int&gt;::max(); </pre><p> This works, though I suspect the actual cut-off point is greater than the max int as (max int + 1 ) and (max int + 2) also work, while (max uint32_t - 2) exhibits the problem. Probably related somehow to the Unix year 2038 problem... I'll probably work around this problem entirely by relying on condition::wait for an infinite wait, rather than abusing timed_wait in this way, but it would be nice to know what the limits are, given that at the xtime level I'm staying within the limits expressed by the type. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Anthony Williams</dc:creator> <pubDate>Fri, 23 May 2008 19:40:47 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/1268#comment:4 https://svn.boost.org/trac10/ticket/1268#comment:4 <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">wontfix</span> </li> </ul> <p> xtime is deprecated in 1.35 </p> Ticket