Skip to content

Commit

Permalink
Circumvent ASAN false positive
Browse files Browse the repository at this point in the history
Summary:
Changes:
* checks if ASAN mode is on, and uses malloc and free in the constructor and destructor
Closes facebook#2767

Differential Revision: D5671243

Pulled By: armishra

fbshipit-source-id: 8e4ad0f7f163400c4effa8617d3b30134119d802
  • Loading branch information
armishra authored and facebook-github-bot committed Aug 21, 2017
1 parent 5b68b11 commit 09ac620
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cache/lru_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,35 @@ void LRUCacheShard::EvictFromLRU(size_t charge,
}

void* LRUCacheShard::operator new(size_t size) {
#if __SANITIZE_ADDRESS__
return malloc(size);
#else
return port::cacheline_aligned_alloc(size);
#endif
}

void* LRUCacheShard::operator new[](size_t size) {
#if __SANITIZE_ADDRESS__
return malloc(size);
#else
return port::cacheline_aligned_alloc(size);
#endif
}

void LRUCacheShard::operator delete(void *memblock) {
#if __SANITIZE_ADDRESS__
free(memblock);
#else
port::cacheline_aligned_free(memblock);
#endif
}

void LRUCacheShard::operator delete[](void* memblock) {
#if __SANITIZE_ADDRESS__
free(memblock);
#else
port::cacheline_aligned_free(memblock);
#endif
}

void LRUCacheShard::SetCapacity(size_t capacity) {
Expand Down

0 comments on commit 09ac620

Please sign in to comment.