<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 - ASSERTION FAILED: m_state == Initialized in ubresourceLoader::didReceiveResponse()"
href="https://bugs.webkit.org/show_bug.cgi?id=150327">150327</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ASSERTION FAILED: m_state == Initialized in ubresourceLoader::didReceiveResponse()
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>WebKit Local Build
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Unspecified
</td>
</tr>
<tr>
<th>OS</th>
<td>Unspecified
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Keywords</th>
<td>Gtk, LayoutTestFailure
</td>
</tr>
<tr>
<th>Severity</th>
<td>Normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>Page Loading
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>cgarcia@igalia.com
</td>
</tr>
<tr>
<th>CC</th>
<td>darin@apple.com, koivisto@iki.fi
</td>
</tr></table>
<p>
<div>
<pre>This happens with printing/print-close-crash.html in the GTK+ port. This is how it happens:
1. print() is called while the document is still loading, so m_shouldPrintWhenFinishedLoading is set to true
2. DataURLDecoder::decode() finishes in the work queue thread, the completion handler is scheduled in the main thread
3. The load is cancelled
3.1 SubresourceLoader::willCancel sets m_state = Finishing
3.2 DOMWindow::finishedLoading() is called, and since m_shouldPrintWhenFinishedLoading is true, it does the print.
3.3 Cancellation finishes and ResourceLoader::releaseResources() si called that sets m_reachedTerminalState = true
So, between 3.1 and 3.3, the state is finishing, but m_reachedTerminalState is false. What happens, in the GTK+ port at least, is that the nested main loop used to make print() synchronous, processes the DataURLDecoder::decode() completion handler that was pending. The completion handler returns early if m_reachedTerminalState is true, but it's not yet in this particular case. So, it ends up calling didReceiveResponse (because the decode didn't fail) when the subresource loader state is Finishing.
I think there are two things here. One is that we shouldn't start a print that was waiting for the load to finish when it failed. That would fix the problem. But it's probably a good idea to also check for cancellation in the DataURLDecoder::decode() completion handler.</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>