diff --git a/FEXCore/include/FEXCore/Debug/InternalThreadState.h b/FEXCore/include/FEXCore/Debug/InternalThreadState.h index 3dc710a9db..b8b6bb32f7 100644 --- a/FEXCore/include/FEXCore/Debug/InternalThreadState.h +++ b/FEXCore/include/FEXCore/Debug/InternalThreadState.h @@ -104,7 +104,6 @@ struct InternalThreadState : public FEXCore::Allocator::FEXAllocOperators { NonMovableUniquePtr PassManager; NonMovableUniquePtr SymbolBuffer; - int StatusCode {}; FEXCore::Context::ExitReason ExitReason {FEXCore::Context::ExitReason::EXIT_WAITING}; std::shared_ptr CompileService; diff --git a/Source/Tools/FEXLoader/FEXLoader.cpp b/Source/Tools/FEXLoader/FEXLoader.cpp index 25655a3ff4..925a06b671 100644 --- a/Source/Tools/FEXLoader/FEXLoader.cpp +++ b/Source/Tools/FEXLoader/FEXLoader.cpp @@ -674,7 +674,7 @@ int main(int argc, char** argv, char** const envp) { } } - auto ProgramStatus = ParentThread->Thread->StatusCode; + auto ProgramStatus = ParentThread->StatusCode; SignalDelegation->UninstallTLSState(ParentThread); SyscallHandler->TM.DestroyThread(ParentThread); diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp index 7f2313b03e..d7b8407ea8 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp @@ -226,7 +226,7 @@ uint64_t HandleNewClone(FEX::HLE::ThreadStateObject* Thread, FEXCore::Context::C FEX::HLE::_SyscallHandler->UninstallTLSState(Thread); // The rest of the context remains as is and the thread will continue executing - return Thread->Thread->StatusCode; + return Thread->StatusCode; } static int Clone3Fork(uint32_t flags) { @@ -390,8 +390,6 @@ void RegisterThread(FEX::HLE::SyscallHandler* Handler) { REGISTER_SYSCALL_IMPL_FLAGS(exit, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY | SyscallFlags::NORETURN, [](FEXCore::Core::CpuStateFrame* Frame, int status) -> uint64_t { - auto Thread = Frame->Thread; - // TLS/DTV teardown is something FEX can't control. Disable glibc checking when we leave a pthread. // Since this thread is hard stopping, we can't track the TLS/DTV teardown in FEX's thread handling. FEXCore::Allocator::YesIKnowImNotSupposedToUseTheGlibcAllocator::HardDisable(); @@ -403,7 +401,7 @@ void RegisterThread(FEX::HLE::SyscallHandler* Handler) { syscall(SYSCALL_DEF(futex), ThreadObject->ThreadInfo.clear_child_tid, FUTEX_WAKE, ~0ULL, 0, 0, 0); } - Thread->StatusCode = status; + ThreadObject->StatusCode = status; FEX::HLE::_SyscallHandler->TM.StopThread(ThreadObject); return 0; diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.h b/Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.h index 2ee75277ea..f83bededc0 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.h +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/ThreadManager.h @@ -58,6 +58,8 @@ struct ThreadStateObject : public FEXCore::Allocator::FEXAllocOperators { // personality emulation. uint32_t persona {}; + + int StatusCode {}; }; class ThreadManager final {