From c67d2068988edccd0c732faec3d3c206089482c0 Mon Sep 17 00:00:00 2001 From: Andres Noetzli Date: Fri, 11 Sep 2015 12:32:59 -0700 Subject: [PATCH] Fixed arena_test failure due to malloc_usable_size() Summary: ArenaTest.MemoryAllocatedBytes on Travis failed: https://travis-ci.org/facebook/rocksdb/jobs/79887849 . This is probably due to malloc_usable_size() returning a value greater than the requested size. From the man page: The value returned by malloc_usable_size() may be greater than the requested size of the allocation because of alignment and minimum size constraints. Although the excess bytes can be overwritten by the application without ill effects, this is not good programming practice: the number of excess bytes in an allocation depends on the underlying implementation. Test Plan: make arena_test && ./arena_test Reviewers: rven, anthony, yhchiang, aekmekji, sdong, igor Reviewed By: igor Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D46743 --- util/arena_test.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/util/arena_test.cc b/util/arena_test.cc index a5336eb8b..148d54468 100644 --- a/util/arena_test.cc +++ b/util/arena_test.cc @@ -36,7 +36,7 @@ void MemoryAllocatedBytesTest(size_t huge_page_size) { arena.Allocate(req_sz); } expected_memory_allocated = req_sz * N + Arena::kInlineSize; - ASSERT_EQ(arena.MemoryAllocatedBytes(), expected_memory_allocated); + ASSERT_GE(arena.MemoryAllocatedBytes(), expected_memory_allocated); arena.Allocate(Arena::kInlineSize - 1); @@ -49,13 +49,13 @@ void MemoryAllocatedBytesTest(size_t huge_page_size) { arena.Allocate(req_sz); } if (huge_page_size) { - ASSERT_TRUE(arena.MemoryAllocatedBytes() == + ASSERT_TRUE(arena.MemoryAllocatedBytes() >= expected_memory_allocated + bsz || - arena.MemoryAllocatedBytes() == + arena.MemoryAllocatedBytes() >= expected_memory_allocated + huge_page_size); } else { expected_memory_allocated += bsz; - ASSERT_EQ(arena.MemoryAllocatedBytes(), expected_memory_allocated); + ASSERT_GE(arena.MemoryAllocatedBytes(), expected_memory_allocated); } // requested size > size of a block: @@ -66,7 +66,7 @@ void MemoryAllocatedBytesTest(size_t huge_page_size) { arena.Allocate(req_sz); } expected_memory_allocated += req_sz * N; - ASSERT_EQ(arena.MemoryAllocatedBytes(), expected_memory_allocated); + ASSERT_GE(arena.MemoryAllocatedBytes(), expected_memory_allocated); } // Make sure we didn't count the allocate but not used memory space in