mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-23 12:10:06 +00:00
spirv-fuzz: Assert false in IsApplicable method of TransformationAccessChain (#3528)
… if it is invalid (with null or undefined pointer). In this case, assert false instead of returning false so that the fuzzer fails. Fixes #3185.
This commit is contained in:
parent
680c77fa6c
commit
de1ff50f28
@ -74,9 +74,9 @@ bool TransformationAccessChain::IsApplicable(
|
||||
switch (pointer->opcode()) {
|
||||
case SpvOpConstantNull:
|
||||
case SpvOpUndef:
|
||||
// TODO(https://github.com/KhronosGroup/SPIRV-Tools/issues/3185): When
|
||||
// fuzzing for real we would like an 'assert(false)' here. But we also
|
||||
// want to be able to write negative unit tests.
|
||||
assert(
|
||||
false &&
|
||||
"Access chains should not be created from null/undefined pointers");
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
|
@ -183,15 +183,23 @@ TEST(TransformationAccessChainTest, BasicTest) {
|
||||
100, 43, {80}, MakeInstructionDescriptor(24, SpvOpLoad, 100))
|
||||
.IsApplicable(context.get(), transformation_context));
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Bad: pointer is null
|
||||
ASSERT_FALSE(TransformationAccessChain(
|
||||
100, 45, {80}, MakeInstructionDescriptor(24, SpvOpLoad, 0))
|
||||
.IsApplicable(context.get(), transformation_context));
|
||||
ASSERT_DEATH(
|
||||
TransformationAccessChain(100, 45, {80},
|
||||
MakeInstructionDescriptor(24, SpvOpLoad, 0))
|
||||
.IsApplicable(context.get(), transformation_context),
|
||||
"Access chains should not be created from null/undefined pointers");
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Bad: pointer is undef
|
||||
ASSERT_FALSE(TransformationAccessChain(
|
||||
100, 46, {80}, MakeInstructionDescriptor(24, SpvOpLoad, 0))
|
||||
.IsApplicable(context.get(), transformation_context));
|
||||
ASSERT_DEATH(
|
||||
TransformationAccessChain(100, 46, {80},
|
||||
MakeInstructionDescriptor(24, SpvOpLoad, 0))
|
||||
.IsApplicable(context.get(), transformation_context),
|
||||
"Access chains should not be created from null/undefined pointers");
|
||||
#endif
|
||||
|
||||
// Bad: pointer to result type does not exist
|
||||
ASSERT_FALSE(TransformationAccessChain(
|
||||
|
Loading…
Reference in New Issue
Block a user