Repository navigation
fix(remote-control): fix daemon spawning and resolve Android seccomp SIGSYS crashes (fixes #51) - #52
hihumanzone wants to merge 4 commits into
Conversation
…YS crashes (fixes wallentx#51) - lib/agy_compat.c: add auxiliary compatibility library intercepting syscall() to bypass Android seccomp SIGSYS trap on syscall 788533211 (0x2f000fdb) - lib/agy_helper.c: attempt direct kernel execv() of agy.va39 when running natively on aarch64 to maintain correct /proc/self/exe resolution for Go daemonization - build.sh: compile libagy_compat.so with -nostdlib, set PT_INTERP and RUNPATH on agy.va39 with patchelf, and add libagy_compat.so to DT_NEEDED - install.sh: extract and install libagy_compat.so alongside binaries with full backup and rollback support - workflows: package and verify libagy_compat.so in release archive, add patchelf to build dependencies
There was a problem hiding this comment.
🟡 Changes recommended
The shim’s incompatible Bionic/glibc interfaces and unsafe in-place installation can corrupt memory at launch and crash running processes during installation.
6 open issues
Compile the shim against glibc, not Android/Bionic · New Remove the redundant glibc/lib shim copy · New Format the new C file with the committed clang-format config · New Set PT_INTERP to the runtime installation prefix · New Include the shim in update staging, validation, and rollback · New Install SIGSYS protection synchronously with Go signal setup · New
What changed in this PR
This PR updates the Termux port’s launch and packaging flow to address remote-control daemon spawning failures and Android seccomp crashes reported in #51.
Changes:
- Attempts direct execution of the patched payload on native CPUs while retaining the loader/QEMU fallback.
- Adds a compatibility library with syscall filtering and SIGSYS handling.
- Patches ELF loading metadata and updates installation and release packaging to include the library.
| File | Description |
|---|---|
lib/agy_helper.c |
Attempts direct payload execution to preserve executable identity during daemon spawning. |
lib/agy_compat.c |
Adds syscall filtering, a SIGSYS handler, and a handler-restoration watchdog. |
install.sh |
Installs the compatibility library and adds backup and cleanup handling. |
build.sh |
Builds the library and patches the payload’s interpreter, RUNPATH, and dependencies. |
.github/workflows/pr-check.yml |
Adds patchelf and packages and validates the compatibility library. |
.github/workflows/auto-sync-release.yml |
Includes the compatibility library in release archives. |
Review effort: Max (adaptive)
| # Compile auxiliary compatibility library if present. | ||
| if [[ -f "lib/agy_compat.c" ]]; then | ||
| info "Compiling auxiliary compatibility library..." | ||
| if ! "$local_cc" -O2 -fPIC -shared -nostdlib -o bin/libagy_compat.so lib/agy_compat.c; then |
| install -m 0755 "$EXTRACT_DIR/libagy_compat.so" "$INSTALL_BIN_DIR/libagy_compat.so" || die "Failed to install libagy_compat.so to $INSTALL_BIN_DIR" | ||
| mkdir -p "${TERMUX_PREFIX}/glibc/lib" 2>/dev/null || true | ||
| cp -pf "$EXTRACT_DIR/libagy_compat.so" "${TERMUX_PREFIX}/glibc/lib/libagy_compat.so" 2>/dev/null || true |
| extern int *__errno_location(void); | ||
|
|
||
| static inline void set_errno(int err) { | ||
| int *loc = __errno_location(); |
| # Patch ELF interpreter and RPATH on agy.va39. | ||
| termux_prefix="${PREFIX:-/data/data/com.termux/files/usr}" | ||
| info "Patching ELF interpreter and RPATH on bin/agy.va39..." | ||
| patchelf --set-interpreter "${termux_prefix}/glibc/lib/ld-linux-aarch64.so.1" \ |
|
|
||
| if [[ -f "bin/libagy_compat.so" ]]; then | ||
| info "Adding libagy_compat.so DT_NEEDED dependency to bin/agy.va39..." | ||
| patchelf --add-needed "libagy_compat.so" bin/agy.va39 |
| usleep(AGY_WATCHDOG_INITIAL_DELAY_US); | ||
| install_sigsys_handler(); |
|
Thanks for the PR and for digging into #51, @hihumanzone. First, quick update: Google's official Antigravity CLI now ships a native Android/Termux Bionic binary ( curl -fsSL https://antigravity.google/cli/install.sh | bashIt installs to Separately, holding off on merging this PR as-is due to a few blockers if we do decide to ship a fix in this port:
(If we still need to fix #51 in this port, the |


Summary
Resolves #51 by fixing background daemon spawning failure and Android kernel seccomp
SIGSYScrashes when running remote control (agy remote-control start,agy --remote-control, or/remote-control).Root Cause Analysis
remote-control: cannot open shared object file):lib/agy_helper.cdirectly executed the glibc dynamic linker (ld-linux-aarch64.so.1), causing the Linux kernel to associate/proc/self/exewith the dynamic linker rather than the application binary.os.Executable()was invoked duringagy remote-control startdaemonization, it resolved told.so. The spawned child executedld.so remote-control serve, which failed becauseld.soattempted to loadremote-controlas an ELF shared library.SIGSYS/ Exit 159):InitializeMeshDaemon,primeLocalNetworkAccess) which issue syscall788533211(0x2f000fdb).-ENOSYS, which Go handles gracefully.SECCOMP_RET_TRAP, terminating the process withSIGSYS(exit code 159).Solution
lib/agy_helper.c:patched_binviaexecv(patched_bin, argv). This preserves/proc/self/exeasagy.va39, enabling Go daemonization to locate and spawn the binary correctly.execv(loader, new_argv)for QEMU environments or unpatched binaries.lib/agy_compat.c):syscall()filter intercepting syscall788533211/0x2f000fdband returning-1(errno = ENOSYS), bypassing Android kernel seccomp traps.__errno_locationfrom glibclibc.so.6and compiles cleanly with-nostdlib..clang-format,.clang-tidy, andcppcheckrequirements with zero warnings underWarningsAsErrors: '*'.build.sh:PT_INTERPandRUNPATHonbin/agy.va39usingpatchelf.libagy_compat.soviapatchelf --add-needed, ensuring it is loaded automatically by the glibc dynamic linker.install.sh,pr-check.yml, andauto-sync-release.ymlto package and deploylibagy_compat.soalongsideagyandagy.va39.Verification
clang-format --dry-run --Werror lib/*.cclang-tidy lib/*.c -- -std=gnu11with zero warnings underWarningsAsErrors: '*'cppcheck --enable=warning,performance,portability lib/with zero warningsstrict-termux-clangcompile checks./build.shagy remote-control startdaemonization on native Termux (aarch64) - daemon active and healthyagy --remote-controlinteractive session withoutSIGSYScrashes