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

thread: Apply alternate signal stack to created threads. #1724

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

squidbus
Copy link
Contributor

With guest stacks in place, if the guest asks for a very small stack size we may overflow the stack in our signal handling. Notably this can happen to more threads on macOS, since we use signal handlers more heavily for patching a few instructions not supported by Rosetta 2.

To solve this, apply an alternate signal stack to each thread created. When signal handlers execute they will switch to this alternate stack instead of executing on the thread stack.

Fixes crashes launching CUSA04551 (NieR:Automata) on macOS, probably helps Linux and some other games as well.

@raphaelthegreat raphaelthegreat merged commit cd9fc5d into shadps4-emu:main Dec 10, 2024
10 checks passed
ngoquang2708 pushed a commit to ngoquang2708/shadPS4 that referenced this pull request Dec 10, 2024
rainmakerv3 pushed a commit to rainmakerv3/shadPS4 that referenced this pull request Dec 10, 2024
@C0rn3j
Copy link
Contributor

C0rn3j commented Dec 10, 2024

/build/shadps4-git/src/shadps4/src/core/thread.cpp: 
In member function ‘void Core::NativeThread::Initialize()’:

/build/shadps4-git/src/shadps4/src/core/thread.cpp:147:5: 
error: designator order for field ‘stack_t::ss_flags’ does not match declaration order in ‘const stack_t’

Fails to build on Arch Linux...

I do have an extra patch with 1683 changes in there but those have nothing to do with threads it seems...

EDIT: so 1683 got merged as I was trying this, will retry master without patches just in case, but still doubt it was the issue.

EDIT2: Still an issue.

EDIT3: I think I fixed it? Will send a PR if the build passes...

diegolix29 pushed a commit to diegolix29/shadPS4 that referenced this pull request Dec 10, 2024
MajorP93 added a commit to MajorP93/shadPS4 that referenced this pull request Dec 10, 2024
diegolix29 pushed a commit to diegolix29/shadPS4 that referenced this pull request Dec 11, 2024
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.

3 participants