Commit 345bac76 authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

Test new hypotheses in CloseAndLockAndDisturb

Modify BodyStreamBuffer::CloseAndLockAndDisturb to test new hypotheses
about what is causing the crashes in this function.

1. Test whether IsContextDestroyed() is ever true by adding a CHECK
   if it is.
2. Test whether stream_ can be empty if stream_broken_ is false. Tests
   with a busy loop have indicated that this function is sometimes
   called with stream_broken_ set to true. This raises the question if
   failures still happen when it is false. This CL will cause it to
   CHECK if stream_broken_ is false and stream_ is empty.

This CL causes intentional crashes and should not be left in the beta
version as-is.

BUG=882599

Change-Id: Id71b66c51fcab0e821a411a2a97866c992b3f36d
Reviewed-on: https://chromium-review.googlesource.com/1245040Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594618}
parent cd031b00
...@@ -377,19 +377,20 @@ bool BodyStreamBuffer::IsStreamDisturbedForDCheck() { ...@@ -377,19 +377,20 @@ bool BodyStreamBuffer::IsStreamDisturbedForDCheck() {
} }
void BodyStreamBuffer::CloseAndLockAndDisturb(ExceptionState& exception_state) { void BodyStreamBuffer::CloseAndLockAndDisturb(ExceptionState& exception_state) {
CHECK(!ExecutionContext::From(script_state_)->IsContextDestroyed());
if (stream_broken_) {
exception_state.ThrowDOMException(
DOMExceptionCode::kInvalidStateError,
"Body stream has suffered a fatal error and cannot be disturbed");
return;
}
// Speculative fix for https://crbug.com/882599. Stop the stream from being // Speculative fix for https://crbug.com/882599. Stop the stream from being
// garbage collected while this function is executing. // garbage collected while this function is executing.
// TODO(ricea): Remove this when a better solution is found or if it doesn't // TODO(ricea): Remove this when a better solution is found or if it doesn't
// work. // work.
v8::Local<v8::Value> stream_handle = v8::Local<v8::Value> stream_handle =
stream_.NewLocal(script_state_->GetIsolate()); stream_.NewLocal(script_state_->GetIsolate());
if (stream_handle.IsEmpty()) { CHECK(!stream_handle.IsEmpty());
stream_broken_ = true;
exception_state.ThrowDOMException(
DOMExceptionCode::kInvalidStateError,
"Body stream has suffered a fatal error and cannot be disturbed");
return;
}
base::Optional<bool> is_readable = IsStreamReadable(exception_state); base::Optional<bool> is_readable = IsStreamReadable(exception_state);
if (exception_state.HadException()) if (exception_state.HadException())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment