Commit 3121ffeb authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm][streaming] Only clear the compilation_unit_builder_ if it exists

The CompilationUnitBuilder of the StreamingProcessor is cleared when an
error occurs in the streaming decoder. The clearing of the
CompilationUnitBuilder was guarded by the existence of the
ModuleCompiler, because this ModuleCompiler and the
CompilationUnitBuilder are created together. However, the
CompilationUnitBuilder is reset when the next section after the code
section is processed, whereas the ModuleCompiler exists until the end of
the AsyncCompileJob. With this CL the clearing of the
CompilationUnitBuilder is also guarded by its own existence.

R=clemensh@chromium.org

Bug: chromium:805346
Change-Id: I0e9e9eaff9239fadb21c0f17990da61cbfaa6856
Reviewed-on: https://chromium-review.googlesource.com/883527
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50844}
parent 5c7b1161
......@@ -3964,7 +3964,10 @@ void AsyncStreamingProcessor::FinishAsyncCompileJobWithError(ResultBase error) {
job_->DoSync<AsyncCompileJob::DecodeFail>(std::move(result));
}
compilation_unit_builder_->Clear();
// Clear the {compilation_unit_builder_} if it exists. This is needed
// because there is a check in the destructor of the
// {CompilationUnitBuilder} that it is empty.
if (compilation_unit_builder_) compilation_unit_builder_->Clear();
} else {
job_->DoSync<AsyncCompileJob::DecodeFail>(std::move(result));
}
......
......@@ -974,6 +974,40 @@ STREAM_TEST(TestModuleWithImportedFunction) {
CHECK(tester.IsPromiseFulfilled());
}
STREAM_TEST(TestModuleWithErrorAfterDataSection) {
StreamTester tester;
const uint8_t bytes[] = {
WASM_MODULE_HEADER, // module header
kTypeSectionCode, // section code
U32V_1(1 + SIZEOF_SIG_ENTRY_x_x), // section size
U32V_1(1), // type count
SIG_ENTRY_x_x(kLocalI32, kLocalI32), // signature entry
kFunctionSectionCode, // section code
U32V_1(1 + 1), // section size
U32V_1(1), // functions count
0, // signature index
kCodeSectionCode, // section code
U32V_1(6), // section size
U32V_1(1), // functions count
U32V_1(4), // body size
U32V_1(0), // locals count
kExprGetLocal, // some code
0, // some code
kExprEnd, // some code
kDataSectionCode, // section code
U32V_1(1), // section size
U32V_1(0), // data segment count
kUnknownSectionCode, // section code
U32V_1(1), // invalid section size
};
tester.OnBytesReceived(bytes, arraysize(bytes));
tester.FinishStream();
tester.RunCompilerTasks();
CHECK(tester.IsPromiseRejected());
}
#undef STREAM_TEST
} // namespace wasm
......
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