Common: Don't use MAP_FIXED on Linux #11282
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
MAP_FIXED will clobber any existing memory mapping, and is not safe to use in a multi-threaded environment. Whether we like it or not, we are a multi-threaded environment, because Qt initializes before we get to main(), so it's already too late to safely use MAP_FIXED by the time we get there.
Use MAP_FIXED_NOREPLACE instead. This is how MAP_FIXED should have behaved from the beginning.
Obviously this means you'll need Linux 4.17+ and a semi-recent libc to use PCSX2 now. But if you're running a 6 year old unsupported kernel, you have bigger problems.
Rationale behind Changes
Fixes "random" startup crashes on Meme Linux.
Suggested Testing Steps
Try to crash PCSX2 by repeatedly shutting down+restarting the application.