Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common: Don't use MAP_FIXED on Linux #11282

Merged
merged 1 commit into from
May 21, 2024

Conversation

stenzek
Copy link
Contributor

@stenzek stenzek commented May 21, 2024

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.

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.

Fixes "random" startup crashes.
@stenzek
Copy link
Contributor Author

stenzek commented May 21, 2024

Actions doesn't want to pick up the change, maybe it doesn't like my branch name.... But I've tested this locally, and it does appear to resolve the issue.

@stenzek stenzek merged commit e24d97b into PCSX2:master May 21, 2024
11 of 12 checks passed
@stenzek stenzek deleted the linux-MAP_FIXED-is-dumb branch May 21, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant