-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[Linux] [CPU] Fix crash on game load caused by corrupted global_mutex pointer #2326
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
base: master
Are you sure you want to change the base?
Conversation
|
How does all of that happen at all? Fixing up after an error that has already happened, and state has already been corrupted in unpredictable ways, will just be hiding the problem, not solving it. |
|
I apologize for the approach taken in my previous commit. You're absolutely right, I was attempting to fix symptoms after corruption had already occurred rather than preventing the corruption in the first place. The defensive checks I added merely detect that global_mutex has been corrupted and attempt to restore it, which doesn't solve the underlying problem and could mask more serious issues. The root cause is that guest code is somehow writing to the structure, corrupting the global_mutex pointer field. I'll revert these changes and investigate the actual source of the memory corruption - likely related to stack overflow, red zone violations, or incorrect memory protection around the context structure. Thank you for the guidance. |
Adds comprehensive validation of critical pointers in PPCContext and BuiltinFunction to detect memory corruption before it causes crashes in mutex operations. Key improvements: - Pre-execution validation of global_mutex pointer in Processor::Execute - Post-execution validation to identify which function caused corruption - Enhanced BuiltinFunction arg pointer validation with detailed errors - Added validation in GuestFunction::Call before and after execution These checks help identify the source of memory corruption (likely guest code buffer overflows writing beyond VMX register arrays) and provide detailed diagnostic information including function addresses, thread IDs, and stack pointers. The assertions ensure the emulator fails fast with clear error messages rather than crashing with cryptic segfaults in std::recursive_mutex::unlock().
|
What places in which games is that crash reproducible in, by the way? It may be useful to be able to look at what actually happens there in the future. |
|
Well, at Forza Motorsport 4 in Linux |
|
Linux is an interesting story. In the current form, the
On the Canary branch, though I'm not entirely sure, but it appears that #1339 is used. Which implementation of the Linux calling convention are you testing Xenia with? |
|
I has used: #2228 |
Description
Fixes emulator crashes during game load caused by memory corruption of the
PPCContext::global_mutexpointer.Problem
The emulator would crash with
SIGSEGVinstd::recursive_mutex::unlock()with an invalidthispointer (e.g.,0x1). Analysis of the callstack showed:GuestFunction::Call→std::recursive_mutex::unlock()PPCContext::global_mutexpointer was corruptedSolution
Added defensive validation and restoration of the
global_mutexpointer at three critical points:Processor::Execute: Validates before executing any functionGuestFunction::Call: Validates before executing guest codeBuiltinFunction::Call: Validates builtin arg0 pointer (global mutex reference)When corruption is detected:
Testing