Interrupt fuzzer if invalid program is generated

If a a valid shader is input into Tint an valid shader should be
output, if the output is invalid then there is a bug in Tint.

BUG=tint:721

Change-Id: Id3fe80eeb65fa55276d74e2f4868e276bd52ec86
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50000
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ryan Harrison 2021-05-05 21:12:22 +00:00 committed by Commit Bot service account
parent ba08d7bca3
commit bc94cd68f8
1 changed files with 10 additions and 1 deletions

View File

@ -33,6 +33,15 @@ namespace fuzzers {
__builtin_trap();
}
[[noreturn]] void ValidityErrorReporter() {
auto printer = tint::diag::Printer::create(stderr, true);
printer->write(
"Fuzzing detected valid input program being transformed into an invalid "
"output progam",
{diag::Color::kRed, true});
__builtin_trap();
}
bool ExtractBindingRemapperInputs(const uint8_t** data,
size_t* size,
tint::transform::DataMap* inputs) {
@ -244,7 +253,7 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
if (transform_manager_) {
auto out = transform_manager_->Run(&program, transform_inputs_);
if (!out.program.IsValid()) {
return 0;
ValidityErrorReporter();
}
program = std::move(out.program);