From 5aac22f27741644f01456f16ba48fc96c8312664 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Fri, 27 Nov 2026 18:23:55 -0500 Subject: [PATCH] fix(session): one owner per handoff exit, worker launch answers and spawn edge cases --- .../launcher/runtime/GuestWorkers.kt | 33 ++++++--- .../launcher/session/SessionService.kt | 15 ++-- docs/phantom-processes.md | 10 ++- tools/nativeguest/hook/exec.c | 7 +- tools/nativeguest/hook/handoff.c | 68 +++++++++++++++---- tools/nativeguest/hook/privileged.c | 17 +++-- tools/tests/test_native_hook_handoff.py | 28 +++++--- 7 files changed, 136 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/GuestWorkers.kt b/app/src/main/java/com/droiddeck/launcher/runtime/GuestWorkers.kt index 501ec8792c..8535101162 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/GuestWorkers.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/GuestWorkers.kt @@ -57,7 +57,8 @@ open class GuestWorker : Service() { val ready = Os.poll(arrayOf(poll), GO_TIMEOUT_MS) val got = if (ready > 0) Os.read(go.fileDescriptor, ByteArray(1), 0, 1) else -1 why = "poll $ready revents ${poll.revents} read $got" - got == 1 + // and the answer the app waits for before it reports the launch as started + got == 1 && Os.write(go.fileDescriptor, byteArrayOf(1), 0, 1) == 1 }.getOrElse { why = it.toString(); false } go.close() if (committed) exec(argv, env, fds, targets, fillBinderFd) @@ -134,7 +135,8 @@ open class GuestWorker : Service() { const val RUN = IBinder.FIRST_CALL_TRANSACTION /** An argument, or a variable's whole value, in an app launch: replaced by the number of its kept binder fd. */ const val BINDER_FD_TOKEN = "@DDH_WORKER_BINDER_FD@" - private const val GO_TIMEOUT_MS = 2000 + // Longer than the app may wait for the hook's "go" (GuestWorkers.ACK_TIMEOUT_MS) before it commits + private const val GO_TIMEOUT_MS = 15000 private val BINDER_DEVICES = setOf("/dev/binder", "/dev/hwbinder", "/dev/vndbinder") private const val BINDER_FDS = 900 private const val MOVED_FDS = 1200 @@ -265,6 +267,7 @@ object GuestWorkers { private val warming = java.util.concurrent.atomic.AtomicBoolean(false) private const val WARM_WORKERS = 2 private const val ACK_TIMEOUT_MS = 5000 + private const val ANSWER_TIMEOUT_MS = 5000 private val connections = java.util.concurrent.Executors.newSingleThreadExecutor { Thread(it, "guest-worker-binder").apply { isDaemon = true } } @Volatile private var server: Thread? = null @@ -328,14 +331,15 @@ object GuestWorkers { slot.session = owner slot.onExit = onExit refill(app) - // The worker execs once a byte comes through this pipe: after the reply has reached us, so + // The worker execs once a byte comes through this socket: after the reply has reached us, so // that its exec does not cut the reply off, and after the slot is marked started. Closed // without one, the worker ends without running the program (the caller starts it another way). + // It answers with a byte of its own: without that it gave up waiting, and nothing runs. var go: Array? = null val data = Parcel.obtain() val reply = Parcel.obtain() try { - go = ParcelFileDescriptor.createPipe() + go = ParcelFileDescriptor.createSocketPair() data.writeStringArray(argv.toTypedArray()) data.writeStringArray(env.toTypedArray()) data.writeInt(fds.size) @@ -362,6 +366,14 @@ object GuestWorkers { return -1 } Os.write(go[1].fileDescriptor, byteArrayOf(1), 0, 1) + val answer = StructPollfd().apply { fd = go[1].fileDescriptor; events = OsConstants.POLLIN.toShort() } + val accepted = Os.poll(arrayOf(answer), ANSWER_TIMEOUT_MS) > 0 && Os.read(go[1].fileDescriptor, ByteArray(1), 0, 1) == 1 + if (!accepted) { + Log.w(TAG, "worker ${slot.index} did not take ${argv.firstOrNull()} on") + slot.started = false + release(app, slot) + return -1 + } } catch (e: Exception) { Log.w(TAG, "worker ${slot.index} refused ${argv.firstOrNull()}", e) release(app, slot) @@ -460,16 +472,21 @@ object GuestWorkers { private fun exitStatus(app: Context, pid: Int): Int { if (pid <= 0 || android.os.Build.VERSION.SDK_INT < 30) return -1 val am = app.getSystemService(ActivityManager::class.java) + var recorded = false repeat(20) { am.getHistoricalProcessExitReasons(app.packageName, pid, 1).firstOrNull()?.let { + recorded = true // an exit code only when the process exited itself; a signal number otherwise (a native crash) - return if (it.reason == android.app.ApplicationExitInfo.REASON_EXIT_SELF) (it.status and 0xff) shl 8 - else if (it.status in 1..64) it.status and 0x7f - else OsConstants.SIGKILL // killed by Android with no signal recorded, not a clean exit + if (it.reason == android.app.ApplicationExitInfo.REASON_EXIT_SELF) return (it.status and 0xff) shl 8 + if (it.status in 1..64) return it.status and 0x7f + // Android records the death first and the zygote's status later (as UNKNOWN, 0, then + // EXIT_SELF): a reason without a status may still be completed + if (it.reason != android.app.ApplicationExitInfo.REASON_UNKNOWN) return OsConstants.SIGKILL } Thread.sleep(50) } - return -1 + // killed by Android with no signal recorded, not a clean exit + return if (recorded) OsConstants.SIGKILL else -1 } /** The pids of session [of]'s guest programs running in workers. */ diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index 7b82f34bdf..80ac8f5d8d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -706,9 +706,13 @@ class SessionService : Service() { // this session's worker number: the shared field may be a newer session's by the time it is used var ownWorkers = 0 if (com.droiddeck.launcher.runtime.GuestWorkers.enabled(this)) { - ownWorkers = com.droiddeck.launcher.runtime.GuestWorkers.serve(this) - guestWorkerSession = ownWorkers - guest.add("DD_SPAWN=" + com.droiddeck.launcher.runtime.GuestWorkers.socketName(this)) + // Under the lock a stop takes its number with: a stop either comes first (and this session + // starts no workers) or owns them + ownWorkers = synchronized(stopLock) { + if (gen != sessionGen || !SessionState.running) 0 + else com.droiddeck.launcher.runtime.GuestWorkers.serve(this).also { guestWorkerSession = it } + } + if (ownWorkers > 0) guest.add("DD_SPAWN=" + com.droiddeck.launcher.runtime.GuestWorkers.socketName(this)) } // Proton builds up to 11.12 report X11 text fields under this name. guest.add("BL_LAUNCH_DIR=" + sessionRoot.path) @@ -2337,8 +2341,11 @@ class SessionService : Service() { return } completeNativeSleep() + var workers = 0 val (ended, endedArch) = synchronized(stopLock) { if (gen != null && gen != sessionGen) return + // as it is when running is cleared: startup registers its workers under this lock too + workers = guestWorkerSession cancelQueuedSteamGame() gameExitWatchToken++ // also when startup stopped before the guest ran @@ -2398,7 +2405,6 @@ class SessionService : Service() { FakeInputWriter.releaseAllRingSlots() com.droiddeck.launcher.input.SteamTouchDevice.release() val steamClientMayRun = SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP - val workers = guestWorkerSession val finishAfterTeardown: () -> Unit = { if (prootPid > 1 || auxiliary.isNotEmpty()) { Thread({ @@ -2406,6 +2412,7 @@ class SessionService : Service() { com.droiddeck.launcher.stores.gog.GogComet.end(stoppedSession) auxiliary.forEach { (pid, started) -> teardown(pid, started) } if (prootPid > 1) teardown(prootPid, workerSession = workers) + else com.droiddeck.launcher.runtime.GuestWorkers.stopGuests(workers) killGuestLeftovers() pruneSystemVulkanRuntime() finishSessionStop(status, stoppedGen, collectEnded) diff --git a/docs/phantom-processes.md b/docs/phantom-processes.md index dbad4c705e..66dbaa7d40 100644 --- a/docs/phantom-processes.md +++ b/docs/phantom-processes.md @@ -45,7 +45,9 @@ Source: `frameworks/base/services/core/java/com/android/server/am/PhantomProcess at `PROCESS_STATE_HOME` or below (backgrounded, no foreground service) and a phantom used "excessive" CPU, `killPhantomProcessGroupLocked` kills every phantom of that app **and the app**. -`settings_enable_monitor_phantom_procs=false` (the developer option) switches off both. Raising +`settings_enable_monitor_phantom_procs=false` (the developer option) switches off both on Android +12L and later; Android 12 does not have the setting, and there only the `device_config` limit below +applies. Raising `max_phantom_processes` through `device_config` (shell only) avoids only the first: the excessive-CPU check still runs while monitoring is on. @@ -450,6 +452,12 @@ adb shell device_config get activity_manager max_phantom_processes adb shell device_config get_sync_disabled_for_tests ``` +Android 12 and some Android 13 builds have no `get_sync_disabled_for_tests`; there `adb shell +device_config is_sync_disabled_for_tests` answers only true or false, so it cannot tell `persistent` +from `until_reboot`. Note `none` when it says false. When it says true, sync was already off and +stays off with `persistent`; if it was `until_reboot`, a reboot after the lab no longer turns it +back on, so set `until_reboot` again yourself if you know that was the mode. + ``` tools/phantomlab/build.sh # build/phantomlab.apk, debug-signed adb install -r tools/phantomlab/build/phantomlab.apk diff --git a/tools/nativeguest/hook/exec.c b/tools/nativeguest/hook/exec.c index 462636efc0..e69aad8769 100644 --- a/tools/nativeguest/hook/exec.c +++ b/tools/nativeguest/hook/exec.c @@ -1190,8 +1190,10 @@ static int ddh_spawn_forked(pid_t *pid, const char *path, const posix_spawn_file const posix_spawnattr_t *attr, char *const argv[], char *const envp[]) { if (fa) { const struct ddh_spawn_action *a = (const struct ddh_spawn_action *)fa->__actions; + // A terminal action stays with glibc, which blocks signals around the file actions: here a + // SIGTTOU could stop the child at tcsetpgrp() with the parent waiting on its report. for (int i = 0; i < fa->__used; i++) { - if ((unsigned)a[i].tag > DDH_DO_TCSETPGRP) return -1; + if ((unsigned)a[i].tag >= DDH_DO_TCSETPGRP) return -1; } } int report[2]; @@ -1228,7 +1230,8 @@ static int ddh_spawn_forked(pid_t *pid, const char *path, const posix_spawn_file while (n < 0 && errno == EINTR); close(report[0]); if (n == (ssize_t)sizeof(err)) { - waitpid(child, NULL, 0); + while (waitpid(child, NULL, 0) < 0 && errno == EINTR) { + } return err; } if (pid) *pid = child; diff --git a/tools/nativeguest/hook/handoff.c b/tools/nativeguest/hook/handoff.c index 8caf45ee7a..f94aaa7729 100644 --- a/tools/nativeguest/hook/handoff.c +++ b/tools/nativeguest/hook/handoff.c @@ -16,6 +16,8 @@ #define DDH_CLAIMED 3 #define DDH_HANDED 1 #define DDH_EXITED 2 +#define DDH_TAKEN 4 // its exit is being reported to one waiter +#define DDH_NO_STATUS INT32_MIN #define DDH_MAGIC 0x6464686f #define DDH_TABLE_FD 800 @@ -383,6 +385,7 @@ static void ddh_linger(int flush) { static void ddh_register_group(void); static void ddh_unregister_group(void); static pid_t ddh_logical_pgrp(void); +static pid_t ddh_logical_group(pid_t real); static long ddh_start_time(pid_t pid); // From exit() (on_exit, arg 1) or _exit() (arg NULL) in a worker's own process. @@ -701,6 +704,12 @@ static int ddh_program_listed(const char *list, const char *filename, char *cons // Whether a posix_spawn() of this program should be handed off: glibc's spawn child makes the exec // system call itself, past ddh_try(), so such a spawn is started with fork() and execve() instead. static int ddh_spawn_wanted(const char *path, char *const argv[], char *const envp[]) { + // the hook's exec ends these at once, its posix_spawn() runs them (exec.c): spawned as before + static const char *const exec_stubs[] = {"mandb", "mandb.real", "update-mime-database", "update-desktop-database", + "install-info", "install-sgmlcatalog"}; + for (size_t i = 0; path && i < sizeof(exec_stubs) / sizeof(exec_stubs[0]); i++) { + if (strcmp(ddh_base(path), exec_stubs[i]) == 0) return 0; + } const char *list = ddh_env(envp, "DD_HANDOFF"); return path && ddh_env(envp, "DD_SPAWN") && list && ddh_program_listed(list, path, argv); } @@ -782,9 +791,18 @@ static void ddh_try(const char *filename, char *const argv[], char *const envp[] e->child = me; e->parent = parent; e->real = 0; - e->pad[1] = getpgrp(); // the group waitpid(0) and waitpid(-GROUP) pick it by + // One look at the group: waitpid(0) and waitpid(-GROUP) pick the child by it, and the request + // names the group it stands for from it (the parent can move this child meanwhile). + pid_t real_group = getpgrp(); + e->pad[1] = real_group; + e->status = DDH_NO_STATUS; char cwd[PATH_MAX]; - if (!getcwd(cwd, sizeof(cwd))) strcpy(cwd, "/"); + // A directory with no name (removed) cannot be sent: the exec stays here, in it. + if (!getcwd(cwd, sizeof(cwd))) { + __atomic_store_n(&e->state, DDH_FREE, __ATOMIC_RELEASE); + ddh_debug(envp, "no name for the working directory:", filename); + return; + } // What the program would have inherited here and a worker does not have: ignored signals, the // open-files limit, the umask (ddh_apply_inherited() restores them in the program). unsigned long ignored = 0; @@ -799,6 +817,7 @@ static void ddh_try(const char *filename, char *const argv[], char *const envp[] sigset_t blocked; pid_t anchor = getenv("DDH_WORKER_PID") ? (pid_t)atoi(getenv("DDH_WORKER_PID")) : parent; long parent_start = ddh_start_time(parent), anchor_start = ddh_start_time(anchor); + pid_t group = ddh_logical_group(real_group); unsigned long blocked_bits = 0; if (sigprocmask(SIG_BLOCK, NULL, &blocked) == 0) { for (int sig = 1; sig <= 64 && sig < NSIG; sig++) { @@ -839,7 +858,7 @@ static void ddh_try(const char *filename, char *const argv[], char *const envp[] ddh_puts(&b, ",\"umask\":"); ddh_putint(&b, (long)mask); ddh_puts(&b, ",\"pgid\":"); - ddh_putint(&b, (long)ddh_logical_pgrp()); + ddh_putint(&b, (long)group); ddh_puts(&b, ",\"sigmask\":"); ddh_putint(&b, (long)blocked_bits); ddh_puts(&b, ",\"anchor\":"); @@ -936,11 +955,20 @@ static struct ddh_entry *ddh_find(pid_t child) { for (int i = 0; i < DDH_SLOTS; i++) { struct ddh_entry *e = &g_ddh->e[i]; int st = __atomic_load_n(&e->state, __ATOMIC_ACQUIRE); - if ((st == DDH_HANDED || st == DDH_EXITED) && e->parent == me && e->child == child) return e; + if ((st == DDH_HANDED || st == DDH_EXITED || st == DDH_TAKEN) && e->parent == me && e->child == child) return e; } return NULL; } +// Takes e's exit for one waiter (EXITED to TAKEN): 0 when another waiter has it. +static int ddh_take(struct ddh_entry *e) { + int expected = DDH_EXITED; + return __atomic_compare_exchange_n(&e->state, &expected, DDH_TAKEN, 0, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE); +} + +// Gives a taken exit back, for a later wait (its forked child is not reaped yet). +static void ddh_untake(struct ddh_entry *e) { __atomic_store_n(&e->state, DDH_EXITED, __ATOMIC_RELEASE); } + // Whether a wait for pid (-1: any child, 0: one in our group, -G: one in group G) takes e's child. static int ddh_selects(const struct ddh_entry *e, pid_t pid) { if (pid > 0) return e->child == pid; @@ -954,7 +982,7 @@ static int ddh_any_live(pid_t pid) { for (int i = 0; i < DDH_SLOTS; i++) { struct ddh_entry *e = &g_ddh->e[i]; int st = __atomic_load_n(&e->state, __ATOMIC_ACQUIRE); - if ((st == DDH_HANDED || st == DDH_EXITED) && e->parent == me && ddh_selects(e, pid)) return 1; + if ((st == DDH_HANDED || st == DDH_EXITED || st == DDH_TAKEN) && e->parent == me && ddh_selects(e, pid)) return 1; } return 0; } @@ -996,8 +1024,11 @@ static void ddh_check_gone(void) { continue; } if (now.tv_sec + 1 - e->pad[0] >= 3) { - e->status = SIGKILL; - __atomic_store_n(&e->state, DDH_EXITED, __ATOMIC_RELEASE); + // only where no status was written (the app's or the program's own wins) + int32_t none = DDH_NO_STATUS; + __atomic_compare_exchange_n(&e->status, &none, SIGKILL, 0, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED); + int expected = DDH_HANDED; + __atomic_compare_exchange_n(&e->state, &expected, DDH_EXITED, 0, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED); } } } @@ -1065,22 +1096,32 @@ static pid_t ddh_wait(pid_t pid, int *status, int options, struct rusage *ru) { struct ddh_entry *e = pid > 0 ? ddh_find(pid) : NULL; if (pid > 0 && e) { if (!e->reaped && real(pid, NULL, WNOHANG, NULL) == pid) e->reaped = 1; - if (__atomic_load_n(&e->state, __ATOMIC_ACQUIRE) == DDH_EXITED) { + if (ddh_take(e)) { // the forked child is between its last write and its exit: reap it first, or a later // wait() would report its pid a second time (not blocking for WNOHANG: then later) - if (!e->reaped && !ddh_reap_shim(real, pid, options)) return (options & WNOHANG) ? 0 : -1; + if (!e->reaped && !ddh_reap_shim(real, pid, options)) { + ddh_untake(e); + return (options & WNOHANG) ? 0 : -1; + } if (ru) memset(ru, 0, sizeof(*ru)); ddh_release(e, status); return pid; } if (options & WNOHANG) return 0; - if (interrupted) return -1; + if (interrupted) { + errno = EINTR; + return -1; + } interrupted = ddh_nap() != 0; continue; } if (pid <= 0 && (e = ddh_exited(pid))) { + if (!ddh_take(e)) continue; // another waiter has it pid_t child = e->child; - if (!e->reaped && !ddh_reap_shim(real, child, options)) return (options & WNOHANG) ? 0 : -1; + if (!e->reaped && !ddh_reap_shim(real, child, options)) { + ddh_untake(e); + return (options & WNOHANG) ? 0 : -1; + } if (ru) memset(ru, 0, sizeof(*ru)); ddh_release(e, status); return child; @@ -1179,13 +1220,14 @@ static long ddh_start_time(pid_t pid) { } // The group a process stands for: its worker's (DDH_PGID) while it is in the group its worker leads. -static pid_t ddh_logical_pgrp(void) { - pid_t real = getpgrp(); +static pid_t ddh_logical_group(pid_t real) { const char *worker = getenv("DDH_WORKER_PID"), *group = getenv("DDH_PGID"); if (worker && group && real == (pid_t)atoi(worker)) return (pid_t)atoi(group); return real; } +static pid_t ddh_logical_pgrp(void) { return ddh_logical_group(getpgrp()); } + static char g_ddh_group_entry[96]; static int g_ddh_parent_entry; diff --git a/tools/nativeguest/hook/privileged.c b/tools/nativeguest/hook/privileged.c index b40afa1127..2f3a6f055a 100644 --- a/tools/nativeguest/hook/privileged.c +++ b/tools/nativeguest/hook/privileged.c @@ -442,6 +442,9 @@ int setns(int fd, int nstype) { #ifndef CLOSE_RANGE_CLOEXEC #define CLOSE_RANGE_CLOEXEC (1U << 2) #endif +#ifndef CLOSE_RANGE_UNSHARE +#define CLOSE_RANGE_UNSHARE (1U << 1) +#endif static int close_range_all(unsigned int first, unsigned int last, int flags); @@ -452,13 +455,15 @@ static int close_range_part(unsigned int first, unsigned int last, void *flags) int close_range(unsigned int first, unsigned int last, int flags) { if (!(flags & CLOSE_RANGE_CLOEXEC)) forget_proc_root_range(first, last); // Close-on-exec only (CLOSE_RANGE_CLOEXEC) leaves the translator's files open - if (flags & CLOSE_RANGE_CLOEXEC) { - if (g_cloexec_kept_count > 0) - return for_each_range_without(first, last, g_cloexec_kept_fds, g_cloexec_kept_count, close_range_part, &flags); - } else if (g_kept_fd_count > 0) { - return for_each_range_without(first, last, g_kept_fds, g_kept_fd_count, close_range_part, &flags); + const int *kept = (flags & CLOSE_RANGE_CLOEXEC) ? g_cloexec_kept_fds : g_kept_fds; + int kept_count = (flags & CLOSE_RANGE_CLOEXEC) ? g_cloexec_kept_count : g_kept_fd_count; + if (kept_count == 0) return close_range_all(first, last, flags); + // The table is unshared once, even when every fd in the range is kept (no fd has the top number) + if (flags & CLOSE_RANGE_UNSHARE) { + if (close_range_all(~0U, ~0U, CLOSE_RANGE_UNSHARE) != 0) return -1; + flags &= ~CLOSE_RANGE_UNSHARE; } - return close_range_all(first, last, flags); + return for_each_range_without(first, last, kept, kept_count, close_range_part, &flags); } // glibc's closefrom() makes the close_range system call itself, past the function above diff --git a/tools/tests/test_native_hook_handoff.py b/tools/tests/test_native_hook_handoff.py index bb954eda38..555323ca12 100644 --- a/tools/tests/test_native_hook_handoff.py +++ b/tools/tests/test_native_hook_handoff.py @@ -1,6 +1,7 @@ import errno import json import os +import shutil import signal import socket import struct @@ -122,20 +123,31 @@ class FakeSpawner(threading.Thread): self.requests.append(request) table = fds[request["table"]] program = str(self.root) + request["file"] - proc = subprocess.Popen(list(self.prefix) + [program] + request["argv"][1:]) - conn.sendall(b"pid %d\n" % proc.pid) - # the hook takes the program on with "go"; without it the program must not run + # As a worker does: a process whose pid goes back first, which runs the program only + # once the hook takes it on with "go" + gate_r, gate_w = os.pipe() + pid = os.fork() + if pid == 0: + os.close(gate_w) + if os.read(gate_r, 1) == b"1": + argv = list(self.prefix) + [program] + request["argv"][1:] + os.execv(argv[0] if os.path.isabs(argv[0]) else shutil.which(argv[0]), argv) + os._exit(127) + os.close(gate_r) + conn.sendall(b"pid %d\n" % pid) went = not request.get("ack") or self.read(conn, 3) == b"go\n" conn.close() for fd in fds: if fd != table: os.close(fd) + if went: + os.write(gate_w, b"1") + os.close(gate_w) if not went: - proc.kill() - proc.wait() + os.waitpid(pid, 0) os.close(table) continue - threading.Thread(target=self.report, args=(proc, table, request), daemon=True).start() + threading.Thread(target=self.report, args=(pid, table, request), daemon=True).start() @staticmethod def read(conn, size): @@ -148,8 +160,8 @@ class FakeSpawner(threading.Thread): return data @staticmethod - def report(proc, table, request): - code = proc.wait() + def report(pid, table, request): + code = os.waitstatus_to_exitcode(os.waitpid(pid, 0)[1]) status = (-code) & 0x7F if code < 0 else (code & 0xFF) << 8 entry = 64 + request["slot"] * 32 os.pwrite(table, struct.pack("