Project

General

Profile

Actions

Emulator Issues #5507

closed

mmap failure goes undetected, leading to segfault

Added by plbl4ster over 12 years ago.

Status:
Fixed
Priority:
Normal
Assignee:
-
% Done:

0%

Operating system:
N/A
Issue type:
Bug
Milestone:
Regression:
No
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

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.

Actions #1

Updated by delroth over 12 years ago

  • Status changed from New to Accepted
Actions #2

Updated by plbl4ster over 12 years ago

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.

Actions #3

Updated by sktsqrl over 12 years ago

  • Status changed from Accepted to Fixed

This issue was closed by revision 8dd11bd1c009.

Actions

Also available in: Atom PDF