fuzzing: When fuzzing, always ASSERT, and abort() instead of SIGTRAP

Currently, when we hit an assertion failure, the fuzzer stops
immediately without producing a crash. This patch makes it so that we do
a hard abort instead which will be caught.

Bug: dawn:295, dawn:293
Fixes: dawn:293
Change-Id: Ie00074e84b51c9aa364aba96c11a35659bbba740
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14682
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Austin Eng 2019-12-19 16:07:58 +00:00 committed by Commit Bot service account
parent cf788596f4
commit 5217ad51c5
2 changed files with 19 additions and 1 deletions

View File

@ -15,11 +15,17 @@
#include "common/Assert.h"
#include "common/Log.h"
#include <cstdlib>
void HandleAssertionFailure(const char* file,
const char* function,
int line,
const char* condition) {
dawn::ErrorLog() << "Assertion failure at " << file << ":" << line << " (" << function
<< "): " << condition;
#if defined(DAWN_ABORT_ON_ASSERT)
abort();
#else
DAWN_BREAKPOINT();
#endif
}

View File

@ -25,6 +25,12 @@ if (build_with_chromium) {
dcheck_always_on = false
}
if (build_with_chromium) {
import("//build/config/sanitizers/sanitizers.gni")
} else {
use_fuzzing_engine = false
}
###############################################################################
# Common dawn configs
###############################################################################
@ -43,10 +49,16 @@ config("dawn_internal") {
]
defines = []
if (dawn_always_assert || dcheck_always_on || is_debug) {
if (dawn_always_assert || dcheck_always_on || is_debug ||
use_fuzzing_engine) {
defines += [ "DAWN_ENABLE_ASSERTS" ]
}
if (use_fuzzing_engine) {
# Does a hard abort when an assertion fails so that fuzzers catch and parse the failure.
defines += [ "DAWN_ABORT_ON_ASSERT" ]
}
if (dawn_enable_d3d12) {
defines += [ "DAWN_ENABLE_BACKEND_D3D12" ]
}