<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:fpizlo@apple.com" title="Filip Pizlo <fpizlo@apple.com>"> <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>
</td>
<td>fpizlo@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@apple.com" title="Filip Pizlo <fpizlo@apple.com>"> <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">> As discussed in <<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>>,
> WTF::Condition::waitFor() times out immediately if given a relativeTimeout
> of std::chrono::milliseconds::max(), due to two signed integer overflow bugs
> conspiring against us in Condition::absoluteFromRelative().
>
> The first happens in this comparison:
>
> if (relativeTimeout > Clock::duration::max()) {
>
> std::chrono::duration converts the operands of its inequality operators to
> the type common to both durations (using std::common_type) before performing
> the comparison. In this case that's nanoseconds, and converting
> milliseconds::max() to nanoseconds will overflow since they both use the
> 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">>
> The second happens on this line, for the same reason, except this time the
> conversion is explicit:
>
> Clock::duration myRelativeTimeout =
> std::chrono::duration_cast<Clock::duration>(relativeTimeout);
>
> Since the check that was supposed to protect us from overflowing itself
> 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>