mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
fix(preload): start apps that check for a single thread and stop the first-call allocation hang (#2995)
* fix(preload): look up the native glibc symbol version first so wrapped calls never allocate On x86 the first dlvsym lookup asked for GLIBC_2.17, which only exists on arm64. The failed lookup makes glibc allocate, which deadlocks when the first wrapped call happens inside a program's own allocator setup. Each architecture now asks for its base version first. * fix(zram): start the page-out worker per request instead of keeping a thread in every process Every process that loaded the session preload carried a resident zr-worker thread from its constructor on. Programs that check they are single-threaded before forking or before unshare(CLONE_NEWUSER) failed, for example Chromium's zygote, which could not start its GPU process. The signal handler now starts the worker with a raw clone on a stack the preload maps itself. The worker makes only raw system calls and exits when no request is left, so starting it from the handler is safe and idle processes stay single-threaded. When the worker cannot be started, the process trims inline in small steps as before. * fix(preload): start the page-out worker with the same clone flags as a thread Programs that filter clone to the flag set threads use, as browser sandboxes do, now accept the worker. The kernel clears the stack-busy word and wakes waiters when the worker exits. * fix(preload): page out inline in single-threaded and self-sandboxed processes A process with one thread may be about to check that it is single-threaded before fork or unshare, and a process that added a seccomp filter after it started may trap system calls into its own handler. Neither gets a worker thread now; both trim inline in small steps as before. * fix(preload): check the signalled thread's own seccomp filters before starting the worker Read Seccomp_filters from /proc/thread-self/status so a thread that installed its own filter without TSYNC trims inline instead of calling clone under that filter, and fall back to the inline path when the signal mask cannot be changed. * test(preload): start parked threads with SIGURG already blocked * test(preload): count only page-out workers when checking for leftover threads
This commit is contained in:
1 parent
6af598b25e
commit
183cbd9351
5 files changed
+509
-87
No files matched your search
@@ -99,10 +99,16 @@ available.
|
||||
|
||||
## Threads
|
||||
|
||||
Page-out never runs on a thread of the game. The preload's signal handler only wakes its
|
||||
`zr-worker` thread, which does the `madvise` calls. A forked process
|
||||
without a worker trims inline in steps of at most 32 MiB per request and looks at no more
|
||||
than 512 MiB of its address space each time. The page-out for a suspend and the read-back
|
||||
When a worker can be started, page-out runs outside the game's threads. The preload's signal
|
||||
handler starts a `zr-worker` thread for the request, which does the `madvise` calls and exits once no request
|
||||
is left, so a process that is not paging out has no thread the preload added. Programs that
|
||||
check they are single-threaded before they fork or call `unshare(CLONE_NEWUSER)`, such as
|
||||
Chromium's zygote, keep working. The worker is a bare `clone` with the flags of a normal
|
||||
thread, on a stack the preload maps itself, and makes only raw system calls, so starting it
|
||||
from the signal handler is safe and seccomp filters that only allow thread clones accept it. A
|
||||
process that has a single thread, or whose signalled thread added a seccomp filter after the
|
||||
process started, as browser sandboxes do, gets no worker. When there is no worker, the process trims inline in steps of at most 32 MiB per request and
|
||||
looks at no more than 512 MiB of its address space each time. The page-out for a suspend and the read-back
|
||||
after it are not limited there: they run once, while the process is being stopped or
|
||||
started, and cover all of it. The monitor is a
|
||||
shell loop in the session, outside every game process.
|
||||
|
||||
Reference in new issue
Block a user