Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorws77.cho <ws77.cho@samsung.com>2022-11-10 12:12:30 +0300
committerGitHub <noreply@github.com>2022-11-10 12:12:30 +0300
commit39e9c6bcccaad4084311d2b11ccf8b88c734652a (patch)
treedd6fa6fbe9efa22aec1e3d0ca36dc0845bf2620d /src/coreclr/minipal
parentdb213657acc53fc48212867d5728e83d9e36a558 (diff)
Return NULL for mmap fail case on Unix (#78069)
* Return NULL for mmap fail case on Unix If mmap failed, "MAP_FAILED" is returned not "NULL". The windows implememtation of GetRWMapping returns "NULL" for fail case, and the caller function is also checking "NULL". So, change Unix implementation to return "NULL" for fail case. * call memset when mmap succeeds * check MAP_FAILED instead of NULL * return false for failing mmap * Call g_fatalErrorHandler if releasing failed * Update src/coreclr/utilcode/executableallocator.cpp Co-authored-by: Jan Vorlicek <jan.vorlicek@volny.cz> * Fix wrong condition check Co-authored-by: Jan Vorlicek <jan.vorlicek@volny.cz>
Diffstat (limited to 'src/coreclr/minipal')
-rw-r--r--src/coreclr/minipal/Unix/doublemapping.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/coreclr/minipal/Unix/doublemapping.cpp b/src/coreclr/minipal/Unix/doublemapping.cpp
index 57ce0c09f28..cb65e5e284e 100644
--- a/src/coreclr/minipal/Unix/doublemapping.cpp
+++ b/src/coreclr/minipal/Unix/doublemapping.cpp
@@ -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;
@@ -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;