Commit c510b2ad authored by Nathan Bronson's avatar Nathan Bronson Committed by Facebook Github Bot

enable some production CHECK in F14 code

Summary:
Production-enabled assertions have shown value in detecting
a variety of issues that should be impossible but are observed to
occur. This diff adds some checks to F14 that may fail under some types
of memory corruption, tag missearch, or hash miscomputation.

Reviewed By: yfeldblum

Differential Revision: D17739592

fbshipit-source-id: 92c9839ed5dab030350408d704a01c97573e3123
parent b695c6bc
...@@ -437,10 +437,12 @@ struct alignas(kRequiredVectorAlignment) F14Chunk { ...@@ -437,10 +437,12 @@ struct alignas(kRequiredVectorAlignment) F14Chunk {
void setTag(std::size_t index, std::size_t tag) { void setTag(std::size_t index, std::size_t tag) {
FOLLY_SAFE_DCHECK( FOLLY_SAFE_DCHECK(
this != emptyInstance() && tag >= 0x80 && tag <= 0xff, ""); this != emptyInstance() && tag >= 0x80 && tag <= 0xff, "");
FOLLY_SAFE_CHECK(tags_[index] == 0, "");
tags_[index] = static_cast<uint8_t>(tag); tags_[index] = static_cast<uint8_t>(tag);
} }
void clearTag(std::size_t index) { void clearTag(std::size_t index) {
FOLLY_SAFE_CHECK((tags_[index] & 0x80) != 0, "");
tags_[index] = 0; tags_[index] = 0;
} }
...@@ -1696,7 +1698,7 @@ class F14Table : public Policy { ...@@ -1696,7 +1698,7 @@ class F14Table : public Policy {
auto&& srcArg = std::forward<T>(src).buildArgForItem(srcItem); auto&& srcArg = std::forward<T>(src).buildArgForItem(srcItem);
auto const& srcKey = src.keyForValue(srcArg); auto const& srcKey = src.keyForValue(srcArg);
auto hp = splitHash(this->computeKeyHash(srcKey)); auto hp = splitHash(this->computeKeyHash(srcKey));
FOLLY_SAFE_DCHECK(hp.second == srcChunk->tag(i), ""); FOLLY_SAFE_CHECK(hp.second == srcChunk->tag(i), "");
insertAtBlank( insertAtBlank(
allocateTag(fullness, hp), allocateTag(fullness, hp),
hp, hp,
...@@ -1928,7 +1930,7 @@ class F14Table : public Policy { ...@@ -1928,7 +1930,7 @@ class F14Table : public Policy {
Item& srcItem = srcChunk->item(srcI); Item& srcItem = srcChunk->item(srcI);
auto hp = splitHash( auto hp = splitHash(
this->computeItemHash(const_cast<Item const&>(srcItem))); this->computeItemHash(const_cast<Item const&>(srcItem)));
FOLLY_SAFE_DCHECK(hp.second == srcChunk->tag(srcI), ""); FOLLY_SAFE_CHECK(hp.second == srcChunk->tag(srcI), "");
auto dstIter = allocateTag(fullness, hp); auto dstIter = allocateTag(fullness, hp);
this->moveItemDuringRehash(dstIter.itemAddr(), srcItem); this->moveItemDuringRehash(dstIter.itemAddr(), srcItem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment