Emulator Issues #5507
closed
mmap failure goes undetected, leading to segfault
Added by plbl4ster over 12 years ago.
Relates to performance:
No
Relates to maintainability:
No
Description
Source/Core/Common/Src/MemArena.cpp MemArena::CreateView, Memory_TryBase
If for some reason mmap fails (one of the reasons is that not all filesystems support it) and returns -1, dolphin doesn't handle it. Later dolphin tries to dereference it and segfaults, leaving no hint to the user as to why this happened.
- Status changed from New to Accepted
First, I think that CreateView should return 0 if mmap fails, for uniformity with the windows variant. With this change, a message box appears: "Failed finding a memory base". Second, it would be nice to have it write to stderr and logfile that mmap failed on that file. Which gives something along the lines of this diff:
--- Source/Core/Common/Src/MemArena.cpp.0 2012-06-17 14:20:49.000000000 +0000
+++ Source/Core/Common/Src/MemArena.cpp 2012-06-30 16:48:03.000000000 +0000
@@ -63,7 +63,13 @@ void* MemArena::CreateView(s64 offset, s
#ifdef _WIN32
return MapViewOfFile(hMemoryMapping, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size);
#else
-
return mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset);
-
void* retval = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset);
-
if (retval == MAP_FAILED) {
-
NOTICE_LOG(MEMMAP, "mmap on %s failed", ram_temp_file);
-
return 0;
-
} else {
-
return retval;
-
}
#endif
}
Same for CreateViewAt.
- Status changed from Accepted to Fixed
This issue was closed by revision 8dd11bd1c009.
Also available in: Atom
PDF