Commit fd0b3090 authored by Stepan Palamarchuk's avatar Stepan Palamarchuk Committed by Facebook Github Bot

Fix DCHECKs in IOBufQueue

Summary: glog actually tries to pull srtings from these pointers when the checks fail, which obfuscates the error

Reviewed By: yfeldblum

Differential Revision: D6506886

fbshipit-source-id: 0283e02aecaa248b84fca1433d3f29f92c37b2e6
parent fe9d8cad
...@@ -236,7 +236,8 @@ class IOBufQueue { ...@@ -236,7 +236,8 @@ class IOBufQueue {
void dcheckIntegrity() { void dcheckIntegrity() {
// Tail start should always be less than tail end. // Tail start should always be less than tail end.
DCHECK_LE(data_.cachedRange.first, data_.cachedRange.second); DCHECK_LE(
(void*)data_.cachedRange.first, (void*)data_.cachedRange.second);
DCHECK( DCHECK(
data_.cachedRange.first != nullptr || data_.cachedRange.first != nullptr ||
data_.cachedRange.second == nullptr); data_.cachedRange.second == nullptr);
...@@ -376,7 +377,9 @@ class IOBufQueue { ...@@ -376,7 +377,9 @@ class IOBufQueue {
*/ */
void postallocate(uint64_t n) { void postallocate(uint64_t n) {
dcheckCacheIntegrity(); dcheckCacheIntegrity();
DCHECK_LE(cachePtr_->cachedRange.first + n, cachePtr_->cachedRange.second); DCHECK_LE(
(void*)(cachePtr_->cachedRange.first + n),
(void*)cachePtr_->cachedRange.second);
cachePtr_->cachedRange.first += n; cachePtr_->cachedRange.first += n;
} }
...@@ -553,8 +556,10 @@ class IOBufQueue { ...@@ -553,8 +556,10 @@ class IOBufQueue {
void dcheckCacheIntegrity() const { void dcheckCacheIntegrity() const {
// Tail start should always be less than tail end. // Tail start should always be less than tail end.
DCHECK_LE(tailStart_, cachePtr_->cachedRange.first); DCHECK_LE((void*)tailStart_, (void*)cachePtr_->cachedRange.first);
DCHECK_LE(cachePtr_->cachedRange.first, cachePtr_->cachedRange.second); DCHECK_LE(
(void*)cachePtr_->cachedRange.first,
(void*)cachePtr_->cachedRange.second);
DCHECK( DCHECK(
cachePtr_->cachedRange.first != nullptr || cachePtr_->cachedRange.first != nullptr ||
cachePtr_->cachedRange.second == nullptr); cachePtr_->cachedRange.second == nullptr);
...@@ -606,7 +611,8 @@ class IOBufQueue { ...@@ -606,7 +611,8 @@ class IOBufQueue {
if (tailStart_ != cachePtr_->cachedRange.first) { if (tailStart_ != cachePtr_->cachedRange.first) {
auto buf = head_->prev(); auto buf = head_->prev();
DCHECK_EQ( DCHECK_EQ(
buf->writableTail() + buf->tailroom(), cachePtr_->cachedRange.second); (void*)(buf->writableTail() + buf->tailroom()),
(void*)cachePtr_->cachedRange.second);
auto len = cachePtr_->cachedRange.first - tailStart_; auto len = cachePtr_->cachedRange.first - tailStart_;
buf->append(len); buf->append(len);
chainLength_ += len; chainLength_ += len;
......
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