mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
MemArena: report mapping failures instead of returning success
Horizon's CreateView printed 'Fatal error creating the view' and then returned base anyway, so the caller recorded an unmapped address as a live view. Posix's ftruncate failure was logged with a '// Should this be a failure?' - it is: the mmaps afterwards succeed against a short file and the first touch past its end raises SIGBUS, which is only hooked under __APPLE__.
This commit is contained in:
1 parent
67b4b68005
commit
91f08424fd
2 files changed
+10
-4
No files matched your search
@@ -50,11 +50,13 @@ void *MemArena::CreateView(s64 offset, size_t size, void *base) {
|
||||
if (R_FAILED(rc)) {
|
||||
printf("Fatal error creating the view... base: %p offset: %p size: %p src: %p err: %d\n",
|
||||
(void *)base, (void *)offset, (void *)size, (void *)(memoryCodeBase + offset), rc);
|
||||
} else {
|
||||
printf("Created the view... base: %p offset: %p size: %p src: %p err: %d\n",
|
||||
(void *)base, (void *)offset, (void *)size, (void *)(memoryCodeBase + offset), rc);
|
||||
// Returning base here reports success, so the caller happily uses an unmapped address
|
||||
// and we take a fault later with nothing pointing back at this.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
printf("Created the view... base: %p offset: %p size: %p src: %p err: %d\n",
|
||||
(void *)base, (void *)offset, (void *)size, (void *)(memoryCodeBase + offset), rc);
|
||||
return base;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,11 @@ bool MemArena::GrabMemSpace(size_t size) {
|
||||
}
|
||||
if (ftruncate(fd, size) != 0) {
|
||||
ERROR_LOG(Log::MemMap, "Failed to ftruncate %d (%s) to size %08x", (int)fd, ram_temp_file.c_str(), (int)size);
|
||||
// Should this be a failure?
|
||||
// This is a failure: the mmaps below succeed against a short file, and touching a page past
|
||||
// its end raises SIGBUS - which is only hooked on __APPLE__, so elsewhere it's a bare crash.
|
||||
close(fd);
|
||||
fd = -1;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user