diff options
author | 2024-12-19 18:02:16 +0000 | |
---|---|---|
committer | 2024-12-19 18:26:13 +0000 | |
commit | 920b937cd80840dc68c526df6151592ada436c70 (patch) | |
tree | 58e374c1305c8662cbc27c4740ded64843897a84 | |
parent | f9a04e35ce5dbd1b3cf5704ac7574ec4d537aeaa (diff) |
Fix MapAnonymousFailNullError for MAP_FIXED_NOREPLACE
It seems that with extra nudge of MAP_FIXED_NOREPLACE,
the allocation sometimes actually succeeds.
Therefore use address that is definitely already used.
Test: run gtests
Change-Id: Idfece892ab25307385ed6229e78af5810a78ee69
-rw-r--r-- | libartbase/base/mem_map_test.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libartbase/base/mem_map_test.cc b/libartbase/base/mem_map_test.cc index 37f5b5a9fe..2c63539803 100644 --- a/libartbase/base/mem_map_test.cc +++ b/libartbase/base/mem_map_test.cc @@ -355,15 +355,16 @@ TEST_F(MemMapTest, MapAnonymousEmpty) { TEST_F(MemMapTest, MapAnonymousFailNullError) { CommonInit(); + uint8_t* invalid_page[16]; // Use this address as mmap hint address. const size_t page_size = MemMap::GetPageSize(); // Test that we don't crash with a null error_str when mapping at an invalid location. MemMap map = MemMap::MapAnonymous("MapAnonymousInvalid", - reinterpret_cast<uint8_t*>(static_cast<size_t>(page_size)), + reinterpret_cast<uint8_t*>(AlignDown(invalid_page, page_size)), 0x20000, PROT_READ | PROT_WRITE, - /*low_4gb=*/ false, - /*reuse=*/ false, - /*reservation=*/ nullptr, + /*low_4gb=*/false, + /*reuse=*/false, + /*reservation=*/nullptr, nullptr); ASSERT_FALSE(map.IsValid()); } |