From 7bfa1c48389190d5cef6d55ae0764ce29f2da181 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Fri, 20 Aug 2021 23:55:56 -0700 Subject: [PATCH] Linux: Fixes 32-bit sigaltstack Due to an incorrect pointer check, we were never setting the sigaltstack on 32-bit applications. Additionally the stack_t type didn't have the members in the correct order. This fixes wine 32-bit applications where wine sends an application SIGUSR1 and expects the altstack to be used. This is because the altstack has the thread's TEB region at the start of the stack. Without this when the application was getting sent a SIGUSR1, it would remain in the application stack, thus getting an invalid TEB and loading an FS register with zero. --- Source/Tests/LinuxSyscalls/x32/Thread.cpp | 2 +- Source/Tests/LinuxSyscalls/x32/Types.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Tests/LinuxSyscalls/x32/Thread.cpp b/Source/Tests/LinuxSyscalls/x32/Thread.cpp index ce2ede9d0..5a5ccdbf7 100644 --- a/Source/Tests/LinuxSyscalls/x32/Thread.cpp +++ b/Source/Tests/LinuxSyscalls/x32/Thread.cpp @@ -224,7 +224,7 @@ namespace FEX::HLE::x32 { stack_t *ss64_ptr{}; stack_t *old64_ptr{}; - if (ss64_ptr) { + if (ss) { ss64 = *ss; ss64_ptr = &ss64; } diff --git a/Source/Tests/LinuxSyscalls/x32/Types.h b/Source/Tests/LinuxSyscalls/x32/Types.h index 3fab8da1f..52c4bc801 100644 --- a/Source/Tests/LinuxSyscalls/x32/Types.h +++ b/Source/Tests/LinuxSyscalls/x32/Types.h @@ -242,23 +242,23 @@ FEX_ANNOTATE("alias-x86_32-stack_t") FEX_ANNOTATE("fex-match") stack_t32 { compat_ptr ss_sp; - compat_size_t ss_size; int32_t ss_flags; + compat_size_t ss_size; stack_t32() = delete; operator stack_t() const { stack_t ss{}; ss.ss_sp = ss_sp; - ss.ss_size = ss_size; ss.ss_flags = ss_flags; + ss.ss_size = ss_size; return ss; } stack_t32(stack_t ss) : ss_sp {ss.ss_sp} { - ss_size = ss.ss_size; ss_flags = ss.ss_flags; + ss_size = ss.ss_size; } };