Commit 1bc0208b authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Fix error printing in streaming fuzzer

The error message held in {CompilationResult} was not null-terminated,
leading to ASan complaints. Just store it in a {std::string} and use
{c_str()} to get a properly null-terminated C-string.

Drive-by: Enable execution of the fuzzer tests.

R=ahaas@chromium.org

Bug: chromium:1334548, v8:12922
Change-Id: Iafcfd5ce77e49e2aa1ff0910d8718bcd51f83662
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3695356
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81020}
parent ae9f9c67
......@@ -8,16 +8,17 @@ from testrunner.local import testsuite
from testrunner.objects import testcase
SUB_TESTS = [
'inspector',
'json',
'parser',
'regexp',
'regexp_builtins',
'multi_return',
'wasm',
'wasm_async',
'wasm_code',
'wasm_compile',
'inspector',
'json',
'parser',
'regexp',
'regexp_builtins',
'multi_return',
'wasm',
'wasm_async',
'wasm_code',
'wasm_compile',
'wasm_streaming',
]
class VariantsGenerator(testsuite.VariantsGenerator):
......
......@@ -22,14 +22,15 @@ struct CompilationResult {
MOVE_ONLY_WITH_DEFAULT_CONSTRUCTORS(CompilationResult);
bool failed = false;
base::OwnedVector<const char> error_message;
std::string error_message;
// If successful:
uint32_t imported_functions = 0;
uint32_t declared_functions = 0;
static CompilationResult ForFailure(base::Vector<const char> error_message) {
return {true, base::OwnedVector<const char>::Of(error_message)};
static CompilationResult ForFailure(std::string error_message) {
DCHECK(!error_message.empty());
return {true, std::move(error_message)};
}
static CompilationResult ForSuccess(const WasmModule* module) {
......@@ -107,8 +108,7 @@ CompilationResult CompileStreaming(v8_fuzzer::FuzzerSupport* support,
}
if (resolver->failed()) {
return CompilationResult::ForFailure(
base::VectorOf(resolver->error_message()));
return CompilationResult::ForFailure(resolver->error_message());
}
result = CompilationResult::ForSuccess(resolver->native_module()->module());
......@@ -136,8 +136,7 @@ CompilationResult CompileSync(Isolate* isolate, WasmFeatures enabled_features,
->SyncCompile(isolate, enabled_features, &thrower,
ModuleWireBytes{data})
.ToHandle(&module_object)) {
auto result =
CompilationResult::ForFailure(base::CStrVector(thrower.error_msg()));
auto result = CompilationResult::ForFailure(thrower.error_msg());
thrower.Reset();
return result;
}
......@@ -173,8 +172,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (streaming_result.failed != sync_result.failed) {
const char* error_msg = streaming_result.failed
? streaming_result.error_message.begin()
: sync_result.error_message.begin();
? streaming_result.error_message.c_str()
: sync_result.error_message.c_str();
FATAL(
"Streaming compilation did%s fail, sync compilation did%s. "
"Error message: %s\n",
......
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