<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:fpizlo&#64;apple.com" title="Filip Pizlo &lt;fpizlo&#64;apple.com&gt;"> <span class="fn">Filip Pizlo</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - WTF::Condition::waitFor() will time out immediately for relativeTimeout values with very large tick counts"
   href="https://bugs.webkit.org/show_bug.cgi?id=157937">bug 157937</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
               &nbsp;
           </td>
           <td>fpizlo&#64;apple.com
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - WTF::Condition::waitFor() will time out immediately for relativeTimeout values with very large tick counts"
   href="https://bugs.webkit.org/show_bug.cgi?id=157937#c2">Comment # 2</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - WTF::Condition::waitFor() will time out immediately for relativeTimeout values with very large tick counts"
   href="https://bugs.webkit.org/show_bug.cgi?id=157937">bug 157937</a>
              from <span class="vcard"><a class="email" href="mailto:fpizlo&#64;apple.com" title="Filip Pizlo &lt;fpizlo&#64;apple.com&gt;"> <span class="fn">Filip Pizlo</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=157937#c0">comment #0</a>)
<span class="quote">&gt; As discussed in &lt;<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - REGRESSION (r188642): All pages are blank when printing a webpage in iOS Safari"
   href="show_bug.cgi?id=157924">https://bugs.webkit.org/show_bug.cgi?id=157924</a>&gt;,
&gt; WTF::Condition::waitFor() times out immediately if given a relativeTimeout
&gt; of std::chrono::milliseconds::max(), due to two signed integer overflow bugs
&gt; conspiring against us in Condition::absoluteFromRelative().
&gt; 
&gt; The first happens in this comparison:
&gt; 
&gt;         if (relativeTimeout &gt; Clock::duration::max()) {
&gt; 
&gt; std::chrono::duration converts the operands of its inequality operators to
&gt; the type common to both durations (using std::common_type) before performing
&gt; the comparison. In this case that's nanoseconds, and converting
&gt; milliseconds::max() to nanoseconds will overflow since they both use the
&gt; same underlying data type.</span >

Wow!  I did not know about this behavior.  That's so awkward!  I don't think I would have been so enthusiastic about using std::chrono if I had known how overflow-prone it was.

<span class="quote">&gt; 
&gt; The second happens on this line, for the same reason, except this time the
&gt; conversion is explicit:
&gt; 
&gt;         Clock::duration myRelativeTimeout =
&gt;             std::chrono::duration_cast&lt;Clock::duration&gt;(relativeTimeout);
&gt; 
&gt; Since the check that was supposed to protect us from overflowing itself
&gt; overflowed, we now have a negative relative timeout.</span >

Dang, that's too funny.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>