TMP - Add diagnostic assertion on nsBaseChannel::OnDataAvailable called after the channel was cancelled draft
authorLuca Greco <lgreco@mozilla.com>
Mon, 20 Sep 2021 13:27:43 +0200
changeset 3978282 0ca61e642671d3e2321eabe9cf1ea27fdc938bef
parent 3978219 6b98e45514de38f1354dc0be2323edd9e503a908
child 3978283 7bb2f9c2a04d01d1e5585243e5c0b6a029614965
push id731704
push userluca.greco@alcacoop.it
push dateMon, 20 Sep 2021 17:05:39 +0000
treeherdertry@3a558ca230fb [default view] [failures only]
milestone94.0a1
TMP - Add diagnostic assertion on nsBaseChannel::OnDataAvailable called after the channel was cancelled
netwerk/base/nsBaseChannel.cpp
--- a/netwerk/base/nsBaseChannel.cpp
+++ b/netwerk/base/nsBaseChannel.cpp
@@ -920,16 +920,28 @@ nsBaseChannel::OnStopRequest(nsIRequest*
 //-----------------------------------------------------------------------------
 // nsBaseChannel::nsIStreamListener
 
 NS_IMETHODIMP
 nsBaseChannel::OnDataAvailable(nsIRequest* request, nsIInputStream* stream,
                                uint64_t offset, uint32_t count) {
   SUSPEND_PUMP_FOR_SCOPE();
 
+#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
+  if (mCanceled) {
+    nsCString spec("unknown");
+    if (mURI) {
+      mURI->GetSpec(spec);
+    }
+    MOZ_CRASH_UNSAFE_PRINTF(
+        "OnDataAvailable receiving data on canceled channel with URI '%s'",
+        spec.get());
+  }
+#endif
+
   nsresult rv = mListener->OnDataAvailable(this, stream, offset, count);
   if (mSynthProgressEvents && NS_SUCCEEDED(rv)) {
     int64_t prog = offset + count;
     if (NS_IsMainThread()) {
       OnTransportStatus(nullptr, NS_NET_STATUS_READING, prog, mContentLength);
     } else {
       class OnTransportStatusAsyncEvent : public Runnable {
         RefPtr<nsBaseChannel> mChannel;