From d4f66a13f9f44af42295202f5f009e8377f7776c Mon Sep 17 00:00:00 2001 From: sunzibo Date: Wed, 9 Jul 2025 19:11:56 +0800 Subject: [PATCH] bugfix of preview in win Issue: ICL7U1 Signed-off-by: sunzibo Change-Id: I5a868e0c34bc2fac3382100de131bea5df7eb8cc --- common_components/heap/allocator/region_desc.h | 12 +++++------- common_components/heap/allocator/region_manager.cpp | 13 +++++-------- common_components/heap/collector/region_rset.h | 2 +- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/common_components/heap/allocator/region_desc.h b/common_components/heap/allocator/region_desc.h index 210dd11c57..6c4e9ab5b5 100755 --- a/common_components/heap/allocator/region_desc.h +++ b/common_components/heap/allocator/region_desc.h @@ -853,7 +853,7 @@ public: return (GetRegionType() == RegionType::FIXED_PINNED_REGION) || (GetRegionType() == RegionType::FULL_FIXED_PINNED_REGION); } - + bool IsThreadLocalRegion() const { return GetRegionType() == RegionType::THREAD_LOCAL_REGION || @@ -1267,7 +1267,7 @@ public: DCHECK_CC(RegionDesc::IsAliveRegionType(regionType_)); return regionType_; } - + bool IsInRecentSpace() const { RegionType type = GetRegionType(); @@ -1369,12 +1369,10 @@ private: SetResurrectedRegionFlag(0); __atomic_store_n(&metadata.rawPointerObjectCount, 0, __ATOMIC_SEQ_CST); #ifdef USE_HWASAN - ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast(metadata.allocPtr), - nUnit * RegionDesc::UNIT_SIZE); - uintptr_t pAddr = metadata.allocPtr; + uintptr_t pAddr = metadata.regionBase; uintptr_t pSize = nUnit * RegionDesc::UNIT_SIZE; - LOG_COMMON(DEBUG) << std::hex << "set [" << pAddr << - std::hex << ", " << (pAddr + pSize) << ") unpoisoned\n"; + ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast(pAddr), pSize); + LOG_COMMON(DEBUG) << std::hex << "set [" << pAddr << std::hex << ", " << (pAddr + pSize) << ") unpoisoned\n"; #endif } diff --git a/common_components/heap/allocator/region_manager.cpp b/common_components/heap/allocator/region_manager.cpp index 4f5bdc9c4d..e395d58370 100755 --- a/common_components/heap/allocator/region_manager.cpp +++ b/common_components/heap/allocator/region_manager.cpp @@ -443,12 +443,10 @@ void RegionManager::Initialize(size_t nRegion, uintptr_t regionInfoAddr) DLOG(REPORT, "region info @0x%zx+%zu, heap [0x%zx, 0x%zx), unit count %zu", regionInfoAddr, metadataSize, regionHeapStart_, regionHeapEnd_, nRegion); #ifdef USE_HWASAN - ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast(regionInfoAddr), - metadataSize + nRegion * RegionDesc::UNIT_SIZE); const uintptr_t p_addr = regionInfoAddr; const uintptr_t p_size = metadataSize + nRegion * RegionDesc::UNIT_SIZE; - LOG_COMMON(DEBUG) << std::hex << "set [" << p_addr << - std::hex << ", " << p_addr + p_size << ") unpoisoned\n"; + ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast(p_addr), p_size); + LOG_COMMON(DEBUG) << std::hex << "set [" << p_addr << std::hex << ", " << p_addr + p_size << ") unpoisoned\n"; #endif } @@ -593,12 +591,11 @@ RegionDesc *RegionManager::TakeRegion(size_t num, RegionDesc::UnitRole type, boo if (num <= GetInactiveUnitCount()) { uintptr_t addr = inactiveZone_.fetch_add(size); if (addr < regionHeapEnd_ - size) { - region = RegionDesc::InitRegionAt(addr, num, type); - size_t idx = region->GetUnitIdx(); #ifdef _WIN64 - MemoryMap::CommitMemory( - reinterpret_cast(RegionDesc::GetUnitAddress(idx)), num * RegionDesc::UNIT_SIZE); + MemoryMap::CommitMemory(reinterpret_cast(addr), num * RegionDesc::UNIT_SIZE); #endif + region = RegionDesc::InitRegionAt(addr, num, type); + size_t idx = region->GetUnitIdx(); (void)idx; // eliminate compilation warning DLOG(REGION, "take inactive units [%zu+%zu, %zu) at [0x%zx, 0x%zx)", idx, num, idx + num, RegionDesc::GetUnitAddress(idx), RegionDesc::GetUnitAddress(idx + num)); diff --git a/common_components/heap/collector/region_rset.h b/common_components/heap/collector/region_rset.h index 8013167716..dc03f30741 100644 --- a/common_components/heap/collector/region_rset.h +++ b/common_components/heap/collector/region_rset.h @@ -25,7 +25,7 @@ public: { CHECK_CC(regionSize % CARD_SIZE == 0); #ifdef _WIN64 - void* startAddress = VirtualAlloc(NULL, cardCnt * sizeof(uint64_t), MEM_RESERVE, PAGE_READWRITE); + void* startAddress = VirtualAlloc(NULL, cardCnt * sizeof(uint64_t), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); if (startAddress == NULL) { LOG_COMMON(FATAL) << "failed to initialize HeapBitmapManager"; UNREACHABLE_CC(); -- Gitee