Commit Graph
24 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5.5 8e2bb1faed 32-bit: Keep the memory view range reserved, and mask guest addresses to it
Find4GBBase found 256 MB of free address space for the views and then
unmapped it, so the gaps between the views went back to the system. On a
32-bit Android device, a running game had malloc heaps between VRAM and RAM
and GPU driver buffers just past RAM, and masked guest addresses (bits 30-31
cleared) reach a whole GB above base, mostly heap. A stray guest access
landed in those silently instead of faulting, and another thread could even
map something where a view was about to go, which the view's MAP_FIXED then
replaced. That fits the 32-bit-only crashes deep in system libraries and in
our own heap structures.

Keep the range reserved as PROT_NONE and map the views over it, putting the
reservation back when a view is released. Mask out bits 28-29 too on 32-bit
(no valid address has them), so accesses stay inside the reservation.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 23:21:11 +02:00
Henrik Rydgård 91f08424fd 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__.
2026-09-02 18:06:47 +02:00
Francisco Javier Trujillo Mata 96fd0f4bcd Add NO_MMAP flag in the compilation scripts 2024-07-29 17:54:06 +02:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Ethan O'Brien 8426b35a80 Cleanup emscripten libretro build target 2023-08-12 14:38:35 -05:00
M4xw b4f602de85 [MemArena] Opt-out of MemArenaPosix for Switch 2023-06-26 13:58:39 +02:00
M4xw 5b6bc0cea7 [MemArena] Honor MV_MIRROR_PREVIOUS on ReleaseView
Allows for clean teardown of the Memory Map for Switch
2023-06-22 00:01:38 +02:00
Unknown W. Brackets fd245f2863 Common: Correct shm_open() call.
Don't remember what happened here,
this was meant to be shm_open().
2021-12-03 14:30:32 -08:00
Unknown W. Brackets 39836e704a Unix: Use shm_open in case not /dev/shm/.
Still falls back to the old behavior if that fails.
2021-09-13 22:20:57 -07:00
Henrik Rydgård 6c51dabe9a Somewhat improved error checking in MemArena. 2021-07-07 19:01:42 +02:00
Henrik Rydgård a40b1dec5f Use Path for fullName in dirlisting. Bugfixes.
Buildfixes

UWP: Buildfix.

headless: Buildfix.

Common: Buildfix.

iOS: Buildfixes.

libretro: Buildfix.

Qt: Buildfix.
2021-05-13 10:39:16 +02:00
Gleb Mazovetskiy 0fb42e07a6 CMake: Rename USE_ADDRESS_SANITIZER to USE_ASAN
For consistency with USE_UBSAN
2021-01-29 23:10:22 +00:00
Jan Beich 633ba355ee Linux: ignore missing MAP_NORESERVE on FreeBSD
Common/MemArenaPosix.cpp:111:71: error: use of undeclared identifier 'MAP_NORESERVE'
        void *base = mmap(0, EIGHT_GIGS, PROT_NONE, MAP_ANON | MAP_PRIVATE | MAP_NORESERVE, -1, 0);
                                                                             ^
2020-12-27 05:25:05 +00:00
Andrew Church 163ed5b5f7 Linux: Properly avoid committing address space for large mmap().
A shared or writable mapping is charged to the process's memory
commitment regardless of MAP_NORESERVE, so the mmap() call to find a
4G base can still fail depending on memory usage and overcommit settings.
2020-12-19 19:45:42 +09:00
Henrik Rydgård 4f43cff5ca Move fileutil, net, image loaders, ui to Common. (#13506)
* Move and rename file_util/fd_util to Common/File/FileUtil and DirListing

Let's also move net while we're at it.

Move the ZIM/PNG loaders over to Common.

Move the UI framework into Common

iOS buildfix

* Buildfix

* Buildfixes

* Apple buildfix

* This typo again..

* UWP buildfix

* Fix build of PPSSPPQt, such as it is (it's not in good condition...)

* Guess what? Another buildfix.
2020-10-04 20:48:47 +02:00
Henrik Rydgård f01ba6dc84 Move NativeApp.h to Common/System, split into NativeApp.h and System.h
Buildfix
2020-10-04 11:42:16 +02:00
Henrik Rydgård 6bcff8cbda Linux: Use MAP_NORESERVE when finding a memory base pointer. See #13187 2020-09-13 17:13:07 +02:00
Unknown W. Brackets 2b49c3e464 MemMap: Check for MAP_FAILED in mmap call. 2020-09-13 00:37:20 -07:00
Henrik Rydgård 617bbcfb87 Step 1 of removing PanicAlert 2020-07-19 20:33:25 +02:00
Henrik Rydgård 1d528d6f3b Linux: Port the proper memory base finding over to MemArenaPosix.cpp.
Who knows, might fix some crashes.
2019-09-01 17:10:13 +02:00
Henrik Rydgård 67b8c4527d b.sh: Add a build option for address sanitizer. When enabled, we turn on some compatibility options to make it work right. 2018-01-31 14:29:23 +01:00
Henrik Rydgård b9bbee5c85 Use the mach memory functions on Mac and 32-bit iOS as well. 2017-01-25 20:38:46 +01:00
Henrik Rydgård 5e61a5afe1 Implement fastmem for Darwin. Not very successfully yet.. 2017-01-25 17:14:43 +01:00
Henrik Rydgard 73a2a1bc0f The MemArena code has way too many ifdefs. Split it up by platform. 2017-01-25 16:20:21 +01:00