fix(fex): signal return restores syscall state; CurseForge runs headless (#3040)

* fix(fex): signal return restores the interrupted syscall state

A guest rt_sigreturn goes through FEX's syscall stub, which marks every
static register as spilled. Returning to unchanged JIT code skipped the
stub's reset, so later asynchronous signals skipped the register spill
and guest handlers read stale registers. CoreCLR's GC suspension reads
and redirects that context, which made x86-64 .NET programs fail with
random access violations. Restore the value saved at signal entry.

* fix(addons): run CurseForge headless from the addon browser, without a session

- The CurseForge source starts the app in its own headless gamescope
  (droiddeck-headless, shared with the Battle.net Agent) instead of a hidden
  session: no SessionService, compositor output or ImageReader.
- The helper's start keeps running until the app exits, so the app lives
  for as long as the addon browser holds that guest command; closing the
  dialog asks the app to quit, stops its process group and cancels the
  command, which ends the app, its gamescope and the guest.
- An app the user already has open is reported busy and left alone.
- Removes BackgroundSession and the CompositorHost start path it shared with
  SessionActivity, with their tests.

* fix(addons): bind each CurseForge stop to its launch and keep the inspector URL out of logs

A stop now only acts on the launch that registered it, so a late stop
from a closed browser cannot end a newer launch, and the browser stops
once. Command logs redact the inspector URL. The signal probe reports a
sender thread that cannot start, sets ECX before the measured region and
its test accepts a valid overshoot of the target count.

* fix(fex): unblock the probe signal before sampling
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-22 20:40:30 -05:00
1 parent 6ef8e2274e
commit 527cb85867
21 files changed
+663 -415

No files matched your search

@@ -0,0 +1,12 @@
diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp
index b4c7b24..e6777aa 100644
--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp
+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp
@@ -262,6 +262,7 @@ void SignalDelegator::RestoreThreadState(FEXCore::Core::InternalThreadState* Thr
if (Context->UContextLocation) {
auto Frame = Thread->CurrentFrame;
+ Frame->InSyscallInfo = Context->InSyscallInfo;
if (Context->Flags & ArchHelpers::Context::ContextFlags::CONTEXT_FLAG_INJIT) {
// XXX: Unsupported since it needs state reconstruction
+84
View File
@@ -0,0 +1,84 @@
#define _GNU_SOURCE
#include <pthread.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <ucontext.h>
#include <unistd.h>
volatile long base;
static volatile long hits, matched, stale, stop;
static long want;
static pid_t target;
extern char probe_loop_start[], probe_loop_end[];
static void handler(int sig, siginfo_t *info, void *context) {
greg_t *g = ((ucontext_t *)context)->uc_mcontext.gregs;
(void)sig;
(void)info;
if (g[REG_RIP] >= (greg_t)probe_loop_start && g[REG_RIP] < (greg_t)probe_loop_end) {
long below = base - g[REG_RSP];
if (g[REG_RBX] == 0x1111111111111111L && g[REG_R12] == 0x2222222222222222L && g[REG_R13] == 0x3333333333333333L &&
g[REG_R14] == 0x4444444444444444L && g[REG_R15] == 0x5555555555555555L && (unsigned long)g[REG_RCX] <= 4096 &&
(below == 0 || below == 8))
matched++;
else
stale++;
}
hits++;
}
static void *sender(void *arg) {
(void)arg;
while (!stop) {
syscall(SYS_tgkill, getpid(), target, SIGUSR1);
usleep(50);
}
return NULL;
}
int main(int argc, char **argv) {
struct sigaction action = {0};
pthread_t thread;
want = argc > 1 ? atol(argv[1]) : 2000;
action.sa_sigaction = handler;
action.sa_flags = SA_SIGINFO | SA_RESTART;
sigaction(SIGUSR1, &action, NULL);
sigset_t usr1;
sigemptyset(&usr1);
sigaddset(&usr1, SIGUSR1);
pthread_sigmask(SIG_UNBLOCK, &usr1, NULL);
target = syscall(SYS_gettid);
if (pthread_create(&thread, NULL, sender, NULL) != 0) {
fprintf(stderr, "cannot start the signal sender\n");
return 2;
}
while (matched + stale < want) {
__asm__ volatile("mov $0x1111111111111111, %%rbx\n"
"mov $0x2222222222222222, %%r12\n"
"mov $0x3333333333333333, %%r13\n"
"mov $0x4444444444444444, %%r14\n"
"mov $0x5555555555555555, %%r15\n"
"mov %%rsp, base(%%rip)\n"
"mov $4096, %%ecx\n"
".globl probe_loop_start\n"
"probe_loop_start:\n"
"push %%rax\n"
"1: dec %%ecx\n"
"jnz 1b\n"
"pop %%rax\n"
"mov $4096, %%ecx\n"
"2: dec %%ecx\n"
"jnz 2b\n"
".globl probe_loop_end\n"
"probe_loop_end:\n"
:
:
: "rbx", "rcx", "r12", "r13", "r14", "r15", "memory");
}
stop = 1;
pthread_join(thread, NULL);
printf("signals=%ld matched=%ld stale=%ld\n", hits, matched, stale);
return stale ? 1 : 0;
}