Turn fuzzers' FatalError into a macro

To enable better bug de-duplication with ClusterFuzz, FatalError has
been turned into a macro. This means that frames one step further down
the stack are considered by the de-duplicator.

Change-Id: Ib5e4a87c9333960178fa17fafff38815293fb053
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/66921
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Alastair Donaldson <afdx@google.com>
This commit is contained in:
Alastair Donaldson 2021-10-19 20:58:43 +00:00 committed by Tint LUCI CQ
parent 8648120bbe
commit c34f08dd45
1 changed files with 15 additions and 10 deletions

View File

@ -37,19 +37,24 @@ namespace fuzzers {
namespace {
[[noreturn]] void FatalError(const tint::diag::List& diags,
const std::string& msg = "") {
auto printer = tint::diag::Printer::create(stderr, true);
if (!msg.empty()) {
printer->write(msg + "\n", {diag::Color::kRed, true});
}
tint::diag::Formatter().format(diags, printer.get());
__builtin_trap();
}
// A macro is used to avoid FatalError creating its own stack frame. This leads
// to better de-duplication of bug reports, because ClusterFuzz only uses the
// top few stack frames for de-duplication, and a FatalError stack frame
// provides no useful information.
#define FatalError(diags, msg_string) \
do { \
std::string msg = msg_string; \
auto printer = tint::diag::Printer::create(stderr, true); \
if (!msg.empty()) { \
printer->write(msg + "\n", {diag::Color::kRed, true}); \
} \
tint::diag::Formatter().format(diags, printer.get()); \
__builtin_trap(); \
} while (false)
[[noreturn]] void TintInternalCompilerErrorReporter(
const tint::diag::List& diagnostics) {
FatalError(diagnostics);
FatalError(diagnostics, "");
}
bool SPIRVToolsValidationCheck(const tint::Program& program,