Delete nullptr in function bb list immedietly (#3326)

When moving blocks around, we ended up with a nullptr for a basic block,
and it was left in the list for a little bit.  However, in that time, it
would end up being dereferenced while traversing the function.

To fix this, we delete it right away.  This was found in an asan build
that runs our current tests.  No new tests are needed, but I did add
extra check asan checks for our asan bot.
This commit is contained in:
Steven Perron 2020-04-28 21:54:08 -04:00 committed by GitHub
parent d0a87194f7
commit 49ca250b44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -46,7 +46,7 @@ fi
ADDITIONAL_CMAKE_FLAGS=""
if [ $CONFIG = "ASAN" ]
then
ADDITIONAL_CMAKE_FLAGS="SPIRV_USE_SANITIZER=address"
ADDITIONAL_CMAKE_FLAGS="SPIRV_USE_SANITIZER=address,bounds,null"
[ $COMPILER = "clang" ] || { echo "$CONFIG requires clang"; exit 1; }
elif [ $CONFIG = "COVERAGE" ]
then

View File

@ -192,13 +192,13 @@ inline void Function::AddBasicBlocks(T src_begin, T src_end, iterator ip) {
}
inline void Function::MoveBasicBlockToAfter(uint32_t id, BasicBlock* ip) {
auto block_to_move = std::move(*FindBlock(id).Get());
std::unique_ptr<BasicBlock> block_to_move = std::move(*FindBlock(id).Get());
blocks_.erase(std::find(std::begin(blocks_), std::end(blocks_), nullptr));
assert(block_to_move->GetParent() == ip->GetParent() &&
"Both blocks have to be in the same function.");
InsertBasicBlockAfter(std::move(block_to_move), ip);
blocks_.erase(std::find(std::begin(blocks_), std::end(blocks_), nullptr));
}
inline void Function::RemoveEmptyBlocks() {