diag: log guest mask changes that block SIGSYS

This commit is contained in:
maxjivi05 committed 2026-12-03 07:36:10 -05:00
1 parent 67e46ce419
commit e4026481ec
1 file changed
+26 -2
+26 -2
View File
@@ -29,10 +29,26 @@ index 1dc85de..dc0b3a1 100644
return {true, SyscallNumber};
}
diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp
index a3cc742..d90d201 100644
index a3cc742..8857e4a 100644
--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp
+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp
@@ -1126,6 +1126,7 @@ void SignalDelegator::PrepareForcedGuestSignal(FEX::HLE::ThreadStateObject* Thre
@@ -334,6 +334,7 @@ void SignalDelegator::RestoreThreadState(FEXCore::Core::InternalThreadState* Thr
auto* GuestUContext = reinterpret_cast<FEXCore::x86_64::ucontext_t*>(Context->UContextLocation);
NewGuestMask = GuestUContext->uc_sigmask.val[0] & ~((1ULL << (SIGKILL - 1)) | (1ULL << (SIGSTOP - 1)));
}
+ if (NewGuestMask & (1ULL << (SIGSYS - 1))) ::dprintf(2, "DDMSKRET %d/%ld new=%#lx saved=%#lx uctx=%#lx rsp=%#lx rip=%#lx\n", ::getpid(), ::syscall(SYS_gettid), static_cast<unsigned long>(NewGuestMask), static_cast<unsigned long>(Context->GuestSignalMask), static_cast<unsigned long>(Context->UContextLocation), static_cast<unsigned long>(Thread->CurrentFrame->State.gregs[FEXCore::X86State::REG_RSP]), static_cast<unsigned long>(Thread->CurrentFrame->State.rip));
ThreadObject->SignalInfo.CurrentSignalMask.Val = NewGuestMask;
CheckForPendingSignals(ThreadObject);
}
@@ -903,6 +904,7 @@ void SignalDelegator::HandleGuestSignal(FEX::HLE::ThreadStateObject* ThreadObjec
GuestNew |= 1ULL << (Signal - 1);
}
GuestNew &= ~((1ULL << (SIGKILL - 1)) | (1ULL << (SIGSTOP - 1)));
+ if (Signal != SIGSYS && (GuestNew & (1ULL << (SIGSYS - 1)))) ::dprintf(2, "DDMSKDLV %d/%ld sig=%d new=%#lx samask=%#lx\n", ::getpid(), ::syscall(SYS_gettid), Signal, static_cast<unsigned long>(GuestNew), static_cast<unsigned long>(Handler.GuestAction.sa_mask.Val));
ThreadObject->SignalInfo.CurrentSignalMask.Val = GuestNew;
NewMask = GuestNew;
for (size_t i = 0; i < MAX_SIGNALS; ++i) {
@@ -1126,6 +1128,7 @@ void SignalDelegator::PrepareForcedGuestSignal(FEX::HLE::ThreadStateObject* Thre
GuestSigAction Action {};
RegisterGuestSignalHandler(Signal, nullptr, &Action);
const bool Ignored = Action.sigaction_handler.handler == SIG_IGN;
@@ -40,3 +56,11 @@ index a3cc742..d90d201 100644
if (!Blocked && !Ignored) {
return;
@@ -1511,6 +1514,7 @@ uint64_t SignalDelegator::GuestSigProcMask(FEX::HLE::ThreadStateObject* Thread,
return -EINVAL;
}
+ if (Thread->SignalInfo.CurrentSignalMask.Val & (1ULL << (SIGSYS - 1))) ::dprintf(2, "DDMSKPROC %d/%ld how=%d set=%#lx new=%#lx\n", ::getpid(), ::syscall(SYS_gettid), how, static_cast<unsigned long>(*set), static_cast<unsigned long>(Thread->SignalInfo.CurrentSignalMask.Val));
uint64_t HostMask = Thread->SignalInfo.CurrentSignalMask.Val;
// Now actually set the host mask
// This will hide from the guest that we are not actually setting all of the masks it wants