From 4ef9763d2fd8bc1b519c04e85875eabae936929c Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Fri, 17 Feb 2023 16:18:07 +0300 Subject: [PATCH 1/5] Fix MapRWAnonymousFixedRaw() mmap is discarded existing mapping with MAP_FIXED flag, so it can caused the app to crash when app had already occupied the required address spaces, after which it started loading the arkruntime. Signed-off-by: Vyacheslav Cherkashin --- libpandabase/tests/mmap_fixed_test.cpp | 2 +- platforms/unix/libpandabase/mem.cpp | 6 +++--- platforms/unix/libpandabase/unix_mem.h | 2 +- platforms/windows/libpandabase/mem.cpp | 3 ++- platforms/windows/libpandabase/windows_mem.h | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libpandabase/tests/mmap_fixed_test.cpp b/libpandabase/tests/mmap_fixed_test.cpp index 955ffe34c..0eb7b726a 100644 --- a/libpandabase/tests/mmap_fixed_test.cpp +++ b/libpandabase/tests/mmap_fixed_test.cpp @@ -45,7 +45,7 @@ TEST_F(MMapFixedTest, MMapAsanTsanTest) end_addr = AlignUp(end_addr, sizeof(uint64_t)); void *result = // NOLINTNEXTLINE(hicpp-signed-bitwise) mmap(ToVoidPtr(cur_addr), MMAP_ALLOC_SIZE, MMAP_PROT_READ | MMAP_PROT_WRITE, - MMAP_FLAG_PRIVATE | MMAP_FLAG_ANONYMOUS | MMAP_FLAG_FIXED, -1, 0); + MMAP_FLAG_PRIVATE | MMAP_FLAG_ANONYMOUS | MMAP_FLAG_FIXED_NOREPLACE, -1, 0); ASSERT_TRUE(result != nullptr); #if (defined(PANDA_TSAN_ON) || defined(USE_THREAD_SANITIZER)) && defined(PANDA_TARGET_ARM64) diff --git a/platforms/unix/libpandabase/mem.cpp b/platforms/unix/libpandabase/mem.cpp index 5e857b22c..147bfd142 100644 --- a/platforms/unix/libpandabase/mem.cpp +++ b/platforms/unix/libpandabase/mem.cpp @@ -223,9 +223,9 @@ void *MapRWAnonymousFixedRaw(void *mem, size_t size, bool force_poison) } #endif ASSERT(size % GetPageSize() == 0); - void *result = // NOLINTNEXTLINE(hicpp-signed-bitwise) - mmap(mem, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); - if (result == reinterpret_cast(-1)) { + int map_flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED_NOREPLACE; + void *result = mmap(mem, size, PROT_READ | PROT_WRITE, map_flags, -1, 0); + if (result == MAP_FAILED) { result = nullptr; } if ((result != nullptr) && force_poison) { diff --git a/platforms/unix/libpandabase/unix_mem.h b/platforms/unix/libpandabase/unix_mem.h index 8e6a44f70..af472c4a0 100644 --- a/platforms/unix/libpandabase/unix_mem.h +++ b/platforms/unix/libpandabase/unix_mem.h @@ -27,8 +27,8 @@ static constexpr uint32_t MMAP_PROT_EXEC = PROT_EXEC; static constexpr uint32_t MMAP_FLAG_SHARED = MAP_SHARED; static constexpr uint32_t MMAP_FLAG_PRIVATE = MAP_PRIVATE; -static constexpr uint32_t MMAP_FLAG_FIXED = MAP_FIXED; static constexpr uint32_t MMAP_FLAG_ANONYMOUS = MAP_ANONYMOUS; +static constexpr uint32_t MMAP_FLAG_FIXED_NOREPLACE = MAP_FIXED_NOREPLACE; } // namespace panda::os::mem #endif // PANDA_LIBPANDABASE_PBASE_OS_UNIX_UNIX_MEM_H_ diff --git a/platforms/windows/libpandabase/mem.cpp b/platforms/windows/libpandabase/mem.cpp index e4748538a..b27054cef 100644 --- a/platforms/windows/libpandabase/mem.cpp +++ b/platforms/windows/libpandabase/mem.cpp @@ -103,7 +103,8 @@ void *mmap([[maybe_unused]] void *addr, size_t len, uint32_t prot, int flags, in errno = 0; // Skip unsupported combinations of flags: - if (len == 0 || (static_cast(flags) & MMAP_FLAG_FIXED) != 0 || prot == MMAP_PROT_EXEC) { + constexpr int UNSUPPORTED_FLAGS = MMAP_FLAG_FIXED_NOREPLACE; + if (len == 0 || flags & UNSUPPORTED_FLAGS || prot == MMAP_PROT_EXEC) { errno = EINVAL; return MAP_FAILED; } diff --git a/platforms/windows/libpandabase/windows_mem.h b/platforms/windows/libpandabase/windows_mem.h index 313206116..fb536cd0f 100644 --- a/platforms/windows/libpandabase/windows_mem.h +++ b/platforms/windows/libpandabase/windows_mem.h @@ -25,8 +25,8 @@ static constexpr uint32_t MMAP_PROT_EXEC = 4; static constexpr uint32_t MMAP_FLAG_SHARED = 1; static constexpr uint32_t MMAP_FLAG_PRIVATE = 2; -static constexpr uint32_t MMAP_FLAG_FIXED = 0x10; static constexpr uint32_t MMAP_FLAG_ANONYMOUS = 0x20; +static constexpr uint32_t MMAP_FLAG_FIXED_NOREPLACE = 0x100000; void *mmap([[maybe_unused]] void *addr, size_t len, uint32_t prot, int flags, int fildes, off_t off); -- Gitee From 8cf42996aa0d40037a2f8b18f6cdc08e197d90c3 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 20 Feb 2023 14:41:31 +0300 Subject: [PATCH 2/5] Fix alloc memory for MmapMemPool Signed-off-by: Vyacheslav Cherkashin --- compiler/docs/aot_resolve_string.md | 2 +- compiler/optimizer/ir/runtime_interface.h | 2 +- libpandabase/mem/mem.h | 4 ++-- libpandabase/mem/mmap_mem_pool-inl.h | 22 +++++++++++++++----- libpandabase/os/mem.h | 12 +++++++++-- libpandafile/file.cpp | 4 ++-- libziparchive/tests/libziparchive_tests.cpp | 6 +++--- platforms/unix/libpandabase/mem.cpp | 13 +++++++----- platforms/unix/libpandabase/unix_mem.h | 3 ++- platforms/windows/libpandabase/mem.cpp | 16 +++++++------- platforms/windows/libpandabase/windows_mem.h | 1 + runtime/mem/region_space.h | 4 ---- 12 files changed, 56 insertions(+), 33 deletions(-) diff --git a/compiler/docs/aot_resolve_string.md b/compiler/docs/aot_resolve_string.md index e10302022..679fc240d 100644 --- a/compiler/docs/aot_resolve_string.md +++ b/compiler/docs/aot_resolve_string.md @@ -33,7 +33,7 @@ There are two options controlling when and how many string will be saved into PL things: - checks the value already stored in `STRING_SLOT` PLT-slot - after AOT-file loading all such slots contain `0` and then each resolution attempt will increment value inside the slot until it either get replaced with a string pointer, - or it reaches `PANDA_32BITS_HEAP_START_ADDRESS - 1` (after that invocations will not increment slot value); + or it reaches `PANDA_32BITS_HEAP_ADDRESS_MIN_POSSIBLE - 1` (after that invocations will not increment slot value); - if PLT-slot's value is already a pointer then the resolved string gets returned; - if amount of already filled PLT-slots is above `--resolve-string-aot-threshold` then the resolved string gets returned; diff --git a/compiler/optimizer/ir/runtime_interface.h b/compiler/optimizer/ir/runtime_interface.h index 800590150..ca4ab1c39 100644 --- a/compiler/optimizer/ir/runtime_interface.h +++ b/compiler/optimizer/ir/runtime_interface.h @@ -62,7 +62,7 @@ public: using FieldIndex = uint16_t; using TypeIndex = uint16_t; - static const uintptr_t RESOLVE_STRING_AOT_COUNTER_LIMIT = PANDA_32BITS_HEAP_START_ADDRESS; + static const uintptr_t RESOLVE_STRING_AOT_COUNTER_LIMIT = PANDA_32BITS_HEAP_ADDRESS_MIN_POSSIBLE; struct NamedAccessProfileData { ClassPtr klass; diff --git a/libpandabase/mem/mem.h b/libpandabase/mem/mem.h index 0fbc641f9..c67f29205 100644 --- a/libpandabase/mem/mem.h +++ b/libpandabase/mem/mem.h @@ -223,13 +223,13 @@ static_assert(PANDA_DEFAULT_ALLOCATOR_POOL_SIZE % PANDA_POOL_ALIGNMENT_IN_BYTES constexpr Alignment DEFAULT_FRAME_ALIGNMENT = LOG_ALIGN_6; -constexpr uintptr_t PANDA_32BITS_HEAP_START_ADDRESS = AlignUp(1U, PANDA_POOL_ALIGNMENT_IN_BYTES); +constexpr uintptr_t PANDA_32BITS_HEAP_ADDRESS_MIN_POSSIBLE = AlignUp(1U, PANDA_POOL_ALIGNMENT_IN_BYTES); constexpr uint64_t PANDA_32BITS_HEAP_END_OBJECTS_ADDRESS = 4_GB; inline bool IsAddressInObjectsHeap([[maybe_unused]] uintptr_t address) { #ifdef PANDA_USE_32_BIT_POINTER - return PANDA_32BITS_HEAP_START_ADDRESS <= address && address < PANDA_32BITS_HEAP_END_OBJECTS_ADDRESS; + return PANDA_32BITS_HEAP_ADDRESS_MIN_POSSIBLE <= address && address < PANDA_32BITS_HEAP_END_OBJECTS_ADDRESS; #else // In this case, all 64 bits addresses are valid return true; #endif diff --git a/libpandabase/mem/mmap_mem_pool-inl.h b/libpandabase/mem/mmap_mem_pool-inl.h index 52d0160e2..06b2200c1 100644 --- a/libpandabase/mem/mmap_mem_pool-inl.h +++ b/libpandabase/mem/mmap_mem_pool-inl.h @@ -146,14 +146,26 @@ inline MmapMemPool::MmapMemPool() LOG_MMAP_MEM_POOL(FATAL) << "The memory limits is too high. We can't allocate so much memory from the system"; } ASSERT(object_space_size <= PANDA_MAX_HEAP_SIZE); + void *mem = nullptr; + if (object_space_size != 0) { #if defined(PANDA_USE_32_BIT_POINTER) && !defined(PANDA_TARGET_WINDOWS) - void *mem = panda::os::mem::MapRWAnonymousFixedRaw(ToVoidPtr(PANDA_32BITS_HEAP_START_ADDRESS), object_space_size); - ASSERT((ToUintPtr(mem) == PANDA_32BITS_HEAP_START_ADDRESS) || (object_space_size == 0)); - ASSERT(ToUintPtr(mem) + object_space_size <= PANDA_32BITS_HEAP_END_OBJECTS_ADDRESS); + mem = panda::os::mem::MapRWAnonymousFixedRaw(ToVoidPtr(PANDA_32BITS_HEAP_ADDRESS_MIN_POSSIBLE), object_space_size); + ASSERT(mem == nullptr || ToUintPtr(mem) == PANDA_32BITS_HEAP_ADDRESS_MIN_POSSIBLE); + if (mem == nullptr) { + LOG_MMAP_MEM_POOL(INFO) << "Cannot allocate heap by fixed address, fix_addr=0x" + << std::hex << PANDA_32BITS_HEAP_ADDRESS_MIN_POSSIBLE; + mem = os::mem::MapRWAnonymousWithAlignmentRaw(object_space_size, PANDA_POOL_ALIGNMENT_IN_BYTES, + os::mem::Space::SPACE_32BIT); + } + if ((ToUintPtr(mem) + object_space_size) > PANDA_MAX_HEAP_SIZE) { + LOG_MMAP_MEM_POOL(FATAL) << "Cannot allocate heap, mem=" << mem; + } + ASSERT(ToUintPtr(mem) + object_space_size <= PANDA_32BITS_HEAP_END_OBJECTS_ADDRESS); #else - // We should get aligned to PANDA_POOL_ALIGNMENT_IN_BYTES size - void *mem = panda::os::mem::MapRWAnonymousWithAlignmentRaw(object_space_size, PANDA_POOL_ALIGNMENT_IN_BYTES); + // We should get aligned to PANDA_POOL_ALIGNMENT_IN_BYTES size + mem = panda::os::mem::MapRWAnonymousWithAlignmentRaw(object_space_size, PANDA_POOL_ALIGNMENT_IN_BYTES); #endif + } LOG_IF(((mem == nullptr) && (object_space_size != 0)), FATAL, MEMORYPOOL) << "MmapMemPool: couldn't mmap " << object_space_size << " bytes of memory for the system"; ASSERT(AlignUp(ToUintPtr(mem), PANDA_POOL_ALIGNMENT_IN_BYTES) == ToUintPtr(mem)); diff --git a/libpandabase/os/mem.h b/libpandabase/os/mem.h index f27e4585e..15acd448e 100644 --- a/libpandabase/os/mem.h +++ b/libpandabase/os/mem.h @@ -284,6 +284,11 @@ using BytePtr = MapPtr; using ConstBytePtr = MapPtr; static_assert(ConstBytePtr::GetPtrOffset() == 0); +enum class Space { + SPACE_ANY, + SPACE_32BIT, +}; + /** * Map the specified file into memory. * The interface is similat to POSIX mmap. @@ -310,10 +315,11 @@ BytePtr MapExecuted(size_t size); * Note: returned memory will be poisoned in ASAN targets, * if you need other behavior - consider to change interface, or use manual unpoisoning. * @param size - size in bytes, should be multiple of PAGE_SIZE + * @param space - type of memory address space * @param force_poison - poison mmaped memory * @return */ -PANDA_PUBLIC_API void *MapRWAnonymousRaw(size_t size, bool force_poison = true); +PANDA_PUBLIC_API void *MapRWAnonymousRaw(size_t size, Space space = Space::SPACE_ANY, bool force_poison = true); /** * Anonymous mmap with READ | WRITE protection for pages. @@ -322,10 +328,12 @@ PANDA_PUBLIC_API void *MapRWAnonymousRaw(size_t size, bool force_poison = true); * if you need other behavior - consider to change interface, or use manual unpoisoning. * @param size - size in bytes, should be multiple of PAGE_SIZE * @param aligment_in_bytes - alignment in bytes, should be multiple of PAGE_SIZE + * @param space - type of memory address space * @param force_poison - poison mmaped memory * @return */ -PANDA_PUBLIC_API void *MapRWAnonymousWithAlignmentRaw(size_t size, size_t aligment_in_bytes, bool force_poison = true); +PANDA_PUBLIC_API void *MapRWAnonymousWithAlignmentRaw(size_t size, size_t aligment_in_bytes, + Space space = Space::SPACE_ANY, bool force_poison = true); // ASAN mapped its structures at this magic address (shadow offset): // see https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm diff --git a/libpandafile/file.cpp b/libpandafile/file.cpp index f83b871c0..1bcea0c2c 100644 --- a/libpandafile/file.cpp +++ b/libpandafile/file.cpp @@ -146,7 +146,7 @@ std::unique_ptr OpenPandaFileFromZipFile(ZipArchiveHandl } size_t size_to_mmap = AlignUp(uncompressed_length, panda::os::mem::GetPageSize()); - void *mem = os::mem::MapRWAnonymousRaw(size_to_mmap, false); + void *mem = os::mem::MapRWAnonymousRaw(size_to_mmap, os::mem::Space::SPACE_ANY, false); if (mem == nullptr) { CloseCurrentFile(handle); OpenPandaFileFromZipErrorHandler(handle); @@ -280,7 +280,7 @@ std::unique_ptr OpenPandaFile(std::string_view location, std::unique_ptr OpenPandaFileFromMemory(const void *buffer, size_t size) { size_t size_to_mmap = AlignUp(size, panda::os::mem::GetPageSize()); - void *mem = os::mem::MapRWAnonymousRaw(size_to_mmap, false); + void *mem = os::mem::MapRWAnonymousRaw(size_to_mmap, os::mem::Space::SPACE_ANY, false); if (mem == nullptr) { return nullptr; } diff --git a/libziparchive/tests/libziparchive_tests.cpp b/libziparchive/tests/libziparchive_tests.cpp index b269cf753..980b992be 100644 --- a/libziparchive/tests/libziparchive_tests.cpp +++ b/libziparchive/tests/libziparchive_tests.cpp @@ -204,7 +204,7 @@ static void UnzipFileCheckTxt(const char *archivename, char *filename, const cha uint32_t size_to_mmap = uncompressed_length % page_size == 0 ? min_pages * page_size : (min_pages + 1) * page_size; // we will use mem in memcmp, so donnot poision it! - void *mem = os::mem::MapRWAnonymousRaw(size_to_mmap, false); + void *mem = os::mem::MapRWAnonymousRaw(size_to_mmap, os::mem::Space::SPACE_ANY, false); if (mem == nullptr) { CloseCurrentFile(zipfile); CloseArchiveFile(zipfile); @@ -317,7 +317,7 @@ static void UnzipFileCheckPandaFile(const char *archivename, char *filename, std uint32_t size_to_mmap = uncompressed_length % page_size == 0 ? min_pages * page_size : (min_pages + 1) * page_size; // we will use mem in memcmp, so donnot poision it! - void *mem = os::mem::MapRWAnonymousRaw(size_to_mmap, false); + void *mem = os::mem::MapRWAnonymousRaw(size_to_mmap, os::mem::Space::SPACE_ANY, false); if (mem == nullptr) { CloseCurrentFile(zipfile); CloseArchiveFile(zipfile); @@ -434,7 +434,7 @@ static void UnzipFileCheckInDirectory(const char *archivename, char *filename, c uint32_t size_to_mmap = uncompressed_length % page_size == 0 ? min_pages * page_size : (min_pages + 1) * page_size; // we will use mem in memcmp, so donnot poision it! - void *mem = os::mem::MapRWAnonymousRaw(size_to_mmap, false); + void *mem = os::mem::MapRWAnonymousRaw(size_to_mmap, os::mem::Space::SPACE_ANY, false); if (mem == nullptr) { CloseCurrentFile(zipfile); CloseArchiveFile(zipfile); diff --git a/platforms/unix/libpandabase/mem.cpp b/platforms/unix/libpandabase/mem.cpp index 147bfd142..53edcff93 100644 --- a/platforms/unix/libpandabase/mem.cpp +++ b/platforms/unix/libpandabase/mem.cpp @@ -162,11 +162,14 @@ size_t GetCacheLineSize() return sz; } -void *MapRWAnonymousRaw(size_t size, bool force_poison) +void *MapRWAnonymousRaw(size_t size, Space space, bool force_poison) { ASSERT(size % GetPageSize() == 0); - // NOLINTNEXTLINE(hicpp-signed-bitwise) - void *result = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + int map_flags = MAP_PRIVATE | MAP_ANONYMOUS; + if (space == Space::SPACE_32BIT) { + map_flags |= MAP_32BIT; + } + void *result = mmap(nullptr, size, PROT_READ | PROT_WRITE, map_flags, -1, 0); if (result == reinterpret_cast(-1)) { result = nullptr; } @@ -183,13 +186,13 @@ std::optional PartiallyUnmapRaw(void *mem, size_t size) return UnmapRaw(mem, size); } -void *MapRWAnonymousWithAlignmentRaw(size_t size, size_t aligment_in_bytes, bool force_poison) +void *MapRWAnonymousWithAlignmentRaw(size_t size, size_t aligment_in_bytes, Space space, bool force_poison) { ASSERT(aligment_in_bytes % GetPageSize() == 0); if (size == 0) { return nullptr; } - void *result = MapRWAnonymousRaw(size + aligment_in_bytes, force_poison); + void *result = MapRWAnonymousRaw(size + aligment_in_bytes, space, force_poison); if (result == nullptr) { return result; } diff --git a/platforms/unix/libpandabase/unix_mem.h b/platforms/unix/libpandabase/unix_mem.h index af472c4a0..2d87a34eb 100644 --- a/platforms/unix/libpandabase/unix_mem.h +++ b/platforms/unix/libpandabase/unix_mem.h @@ -16,7 +16,7 @@ #ifndef PANDA_LIBPANDABASE_PBASE_OS_UNIX_UNIX_MEM_H_ #define PANDA_LIBPANDABASE_PBASE_OS_UNIX_UNIX_MEM_H_ -#include +#include namespace panda::os::mem { @@ -28,6 +28,7 @@ static constexpr uint32_t MMAP_PROT_EXEC = PROT_EXEC; static constexpr uint32_t MMAP_FLAG_SHARED = MAP_SHARED; static constexpr uint32_t MMAP_FLAG_PRIVATE = MAP_PRIVATE; static constexpr uint32_t MMAP_FLAG_ANONYMOUS = MAP_ANONYMOUS; +static constexpr uint32_t MMAP_FLAG_32BIT = MAP_32BIT; static constexpr uint32_t MMAP_FLAG_FIXED_NOREPLACE = MAP_FIXED_NOREPLACE; } // namespace panda::os::mem diff --git a/platforms/windows/libpandabase/mem.cpp b/platforms/windows/libpandabase/mem.cpp index b27054cef..1a20aa1d9 100644 --- a/platforms/windows/libpandabase/mem.cpp +++ b/platforms/windows/libpandabase/mem.cpp @@ -103,7 +103,7 @@ void *mmap([[maybe_unused]] void *addr, size_t len, uint32_t prot, int flags, in errno = 0; // Skip unsupported combinations of flags: - constexpr int UNSUPPORTED_FLAGS = MMAP_FLAG_FIXED_NOREPLACE; + constexpr int UNSUPPORTED_FLAGS = MMAP_FLAG_FIXED_NOREPLACE | MMAP_FLAG_32BIT; if (len == 0 || flags & UNSUPPORTED_FLAGS || prot == MMAP_PROT_EXEC) { errno = EINVAL; return MAP_FAILED; @@ -252,12 +252,14 @@ size_t GetCacheLineSize() return sz; } -void *MapRWAnonymousRaw(size_t size, bool force_poison) +void *MapRWAnonymousRaw(size_t size, Space space, bool force_poison) { ASSERT(size % GetPageSize() == 0); - // NOLINTNEXTLINE(hicpp-signed-bitwise) - void *result = - mmap(nullptr, size, MMAP_PROT_READ | MMAP_PROT_WRITE, MMAP_FLAG_PRIVATE | MMAP_FLAG_ANONYMOUS, -1, 0); + int map_flags = MMAP_FLAG_PRIVATE | MMAP_FLAG_ANONYMOUS; + if (space == Space::SPACE_32BIT) { + map_flags |= MMAP_FLAG_32BIT; + } + void *result = mmap(nullptr, size, MMAP_PROT_READ | MMAP_PROT_WRITE, map_flags, -1, 0); if (UNLIKELY(result == MAP_FAILED)) { result = nullptr; } @@ -276,13 +278,13 @@ std::optional PartiallyUnmapRaw([[maybe_unused]] void *mem, [[maybe_unuse return {}; } -void *MapRWAnonymousWithAlignmentRaw(size_t size, size_t aligment_in_bytes, bool force_poison) +void *MapRWAnonymousWithAlignmentRaw(size_t size, size_t aligment_in_bytes, Space space, bool force_poison) { ASSERT(aligment_in_bytes % GetPageSize() == 0); if (size == 0) { return nullptr; } - void *result = MapRWAnonymousRaw(size + aligment_in_bytes, force_poison); + void *result = MapRWAnonymousRaw(size + aligment_in_bytes, space, force_poison); if (result == nullptr) { return result; } diff --git a/platforms/windows/libpandabase/windows_mem.h b/platforms/windows/libpandabase/windows_mem.h index fb536cd0f..23c8ac23f 100644 --- a/platforms/windows/libpandabase/windows_mem.h +++ b/platforms/windows/libpandabase/windows_mem.h @@ -26,6 +26,7 @@ static constexpr uint32_t MMAP_PROT_EXEC = 4; static constexpr uint32_t MMAP_FLAG_SHARED = 1; static constexpr uint32_t MMAP_FLAG_PRIVATE = 2; static constexpr uint32_t MMAP_FLAG_ANONYMOUS = 0x20; +static constexpr uint32_t MMAP_FLAG_32BIT = 0x40; static constexpr uint32_t MMAP_FLAG_FIXED_NOREPLACE = 0x100000; void *mmap([[maybe_unused]] void *addr, size_t len, uint32_t prot, int flags, int fildes, off_t off); diff --git a/runtime/mem/region_space.h b/runtime/mem/region_space.h index eb6f9bfdf..9de3a2839 100644 --- a/runtime/mem/region_space.h +++ b/runtime/mem/region_space.h @@ -296,11 +296,7 @@ public: static uintptr_t HeapStartAddress() { // see MmapMemPool about the object space start address -#if defined(PANDA_USE_32_BIT_POINTER) && !defined(PANDA_TARGET_WINDOWS) - return PANDA_32BITS_HEAP_START_ADDRESS; -#else return PoolManager::GetMmapMemPool()->GetMinObjectAddress(); -#endif } InternalAllocatorPtr GetInternalAllocator(); -- Gitee From 9b1f639ab8306d888fd320ad2f187a55a6760bca Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Mon, 20 Feb 2023 14:45:07 +0300 Subject: [PATCH 3/5] Fix install toolchain on Ubuntu-20.04 Signed-off-by: Vyacheslav Cherkashin --- scripts/install-deps-ubuntu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install-deps-ubuntu b/scripts/install-deps-ubuntu index c6bd1c821..00f2e84af 100755 --- a/scripts/install-deps-ubuntu +++ b/scripts/install-deps-ubuntu @@ -159,7 +159,7 @@ function enable_test_toolchain_repo cat > /etc/apt/preferences.d/ubuntu-toolchain-r-test << EOF Package: * Pin: release o=LP-PPA-ubuntu-toolchain-r-test -Pin-Priority: 1 +Pin-Priority: 501 EOF apt-get update -- Gitee From 3047e06dc91fbf77b59c5f32123d34fea5ad6385 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Tue, 28 Feb 2023 13:26:17 +0300 Subject: [PATCH 4/5] Revert "Fix install toolchain on Ubuntu-20.04" This reverts commit 14d48e6f07676d3f83e786c341d0a66b0be67837. --- scripts/install-deps-ubuntu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install-deps-ubuntu b/scripts/install-deps-ubuntu index 00f2e84af..c6bd1c821 100755 --- a/scripts/install-deps-ubuntu +++ b/scripts/install-deps-ubuntu @@ -159,7 +159,7 @@ function enable_test_toolchain_repo cat > /etc/apt/preferences.d/ubuntu-toolchain-r-test << EOF Package: * Pin: release o=LP-PPA-ubuntu-toolchain-r-test -Pin-Priority: 501 +Pin-Priority: 1 EOF apt-get update -- Gitee From 5bcf670022c1e271f9415fbfbf2a6c47059b5a45 Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Thu, 2 Mar 2023 11:43:35 +0300 Subject: [PATCH 5/5] fixup! Fix alloc memory for MmapMemPool --- libpandabase/os/mem.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libpandabase/os/mem.h b/libpandabase/os/mem.h index 15acd448e..9b43d202a 100644 --- a/libpandabase/os/mem.h +++ b/libpandabase/os/mem.h @@ -24,6 +24,7 @@ #include #ifdef PANDA_TARGET_UNIX +#include // madvise() #include "platforms/unix/libpandabase/unix_mem.h" #elif PANDA_TARGET_WINDOWS #include "platforms/windows/libpandabase/windows_mem.h" -- Gitee