Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/coreclr/minipal/Unix/doublemapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ bool VMToOSInterface::ReleaseDoubleMappedMemory(void *mapperHandle, void* pStart
{
#ifndef TARGET_OSX
int fd = (int)(size_t)mapperHandle;
mmap(pStart, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, offset);
if (mmap(pStart, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, offset) == MAP_FAILED)
{
return false;
}
memset(pStart, 0, size);
#endif // TARGET_OSX
return munmap(pStart, size) != -1;
Expand All @@ -208,7 +211,12 @@ void* VMToOSInterface::GetRWMapping(void *mapperHandle, void* pStart, size_t off
{
#ifndef TARGET_OSX
int fd = (int)(size_t)mapperHandle;
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset);
void* result = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset);
if (result == MAP_FAILED)
{
result = NULL;
}
return result;
#else // TARGET_OSX
#ifdef TARGET_AMD64
vm_address_t startRW;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Runtime/unix/PalRedhawkUnix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ REDHAWK_PALEXPORT _Ret_maybenull_ _Post_writable_byte_size_(size) void* REDHAWK_

void * pRetVal = mmap(pAddress, alignedSize, unixProtect, flags, -1, 0);

if (pRetVal != NULL)
if (pRetVal != MAP_FAILED)
{
void * pAlignedRetVal = (void *)(((size_t)pRetVal + (Alignment - 1)) & ~(Alignment - 1));
size_t startPadding = (size_t)pAlignedRetVal - (size_t)pRetVal;
Expand Down
5 changes: 4 additions & 1 deletion src/coreclr/utilcode/executableallocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,10 @@ void ExecutableAllocator::Release(void* pRX)

if (pBlock != NULL)
{
VMToOSInterface::ReleaseDoubleMappedMemory(m_doubleMemoryMapperHandle, pRX, pBlock->offset, pBlock->size);
if (!VMToOSInterface::ReleaseDoubleMappedMemory(m_doubleMemoryMapperHandle, pRX, pBlock->offset, pBlock->size))
{
g_fatalErrorHandler(COR_E_EXECUTIONENGINE, W("Releasing the double mapped memory failed"));
}
// Put the released block into the free block list
pBlock->baseRX = NULL;
pBlock->next = m_pFirstFreeBlockRX;
Expand Down