<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><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">157937</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>WTF::Condition::waitFor() will time out immediately for relativeTimeout values with very large tick counts
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>WebKit Nightly Build
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>Major
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>Web Template Framework
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>aestes@apple.com
</td>
</tr></table>
<p>
<div>
<pre>As discussed in <<a class="bz_bug_link
bz_status_NEW "
title="NEW - 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.
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.</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>