Commit a53d4687 authored by jgruber's avatar jgruber Committed by Commit bot

Properly handle exceptions in cctests

Thrown exceptions must be handled before another exception is thrown.
This fixes all remaining test failures exposed by not clearing pending
exceptions in JSEntryStub.

BUG=v8:5259

Review-Url: https://codereview.chromium.org/2207923002
Cr-Commit-Position: refs/heads/master@{#38324}
parent 76193d4b
...@@ -1647,6 +1647,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, ...@@ -1647,6 +1647,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source,
i::Handle<i::String> message_string = i::Handle<i::String>::cast( i::Handle<i::String> message_string = i::Handle<i::String>::cast(
i::JSReceiver::GetProperty(isolate, exception_handle, "message") i::JSReceiver::GetProperty(isolate, exception_handle, "message")
.ToHandleChecked()); .ToHandleChecked());
isolate->clear_pending_exception();
if (result == kSuccess) { if (result == kSuccess) {
v8::base::OS::Print( v8::base::OS::Print(
...@@ -5617,6 +5618,7 @@ TEST(BasicImportExportParsing) { ...@@ -5617,6 +5618,7 @@ TEST(BasicImportExportParsing) {
i::Handle<i::String> message_string = i::Handle<i::String>::cast( i::Handle<i::String> message_string = i::Handle<i::String>::cast(
i::JSReceiver::GetProperty(isolate, exception_handle, "message") i::JSReceiver::GetProperty(isolate, exception_handle, "message")
.ToHandleChecked()); .ToHandleChecked());
isolate->clear_pending_exception();
v8::base::OS::Print( v8::base::OS::Print(
"Parser failed on:\n" "Parser failed on:\n"
...@@ -5637,6 +5639,7 @@ TEST(BasicImportExportParsing) { ...@@ -5637,6 +5639,7 @@ TEST(BasicImportExportParsing) {
i::Parser parser(&info); i::Parser parser(&info);
info.set_global(); info.set_global();
CHECK(!parser.Parse(&info)); CHECK(!parser.Parse(&info));
isolate->clear_pending_exception();
} }
} }
} }
...@@ -5729,6 +5732,7 @@ TEST(ImportExportParsingErrors) { ...@@ -5729,6 +5732,7 @@ TEST(ImportExportParsingErrors) {
i::Parser parser(&info); i::Parser parser(&info);
info.set_module(); info.set_module();
CHECK(!parser.Parse(&info)); CHECK(!parser.Parse(&info));
isolate->clear_pending_exception();
} }
} }
...@@ -5766,6 +5770,7 @@ TEST(ModuleTopLevelFunctionDecl) { ...@@ -5766,6 +5770,7 @@ TEST(ModuleTopLevelFunctionDecl) {
i::Parser parser(&info); i::Parser parser(&info);
info.set_module(); info.set_module();
CHECK(!parser.Parse(&info)); CHECK(!parser.Parse(&info));
isolate->clear_pending_exception();
} }
} }
......
...@@ -62,7 +62,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { ...@@ -62,7 +62,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
v8::TryCatch try_catch(isolate); v8::TryCatch try_catch(isolate);
i::MaybeHandle<i::JSRegExp> maybe_regexp = i::MaybeHandle<i::JSRegExp> maybe_regexp =
i::JSRegExp::New(source, static_cast<i::JSRegExp::Flags>(flags)); i::JSRegExp::New(source, static_cast<i::JSRegExp::Flags>(flags));
if (!maybe_regexp.ToHandle(&regexp)) continue; if (!maybe_regexp.ToHandle(&regexp)) {
i_isolate->clear_pending_exception();
continue;
}
} }
Test(isolate, regexp, one_byte, results_array); Test(isolate, regexp, one_byte, results_array);
Test(isolate, regexp, two_byte, results_array); Test(isolate, regexp, two_byte, results_array);
......
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