Skip to content

Error': system call #17

Closed
Closed

Description

@mozzaru

================================================================
ISSUE REPORT - OpenCode Termux release Push260828 (native/bionic)

TITLE SUGGESTION:
"opencode_1.18.21_aarch64.deb (native bionic) crashes with 'Bad
system call' (SIGSYS / exit 159) on kernel 4.19.152 (Android 11,
API 30)"


  1. SUMMARY

The native (bionic) OpenCode build, version 1.18.21, from the
Push260828 release
(asset: opencode_1.18.21_aarch64.deb), fails to start on this
device with a runtime crash:

Bad system call            ./opencode --version
exit code: 159  (= 128 + 31 -> SIGSYS)

The binary cannot even print its version. In contrast, the glibc
wrapper line build (opencode-glibc 1.18.15) from the same release
works correctly and is fully functional.


  1. DEVICE / ENVIRONMENT

Note: the release notes for the native line state
"Requires Android API >= 28". This device has API level 30, which
satisfies that requirement, yet the binary still crashes.


  1. REPRODUCTION STEPS

  1. Download the native build:
    opencode_1.18.21_aarch64.deb
    from the Push260828 release.

  2. Install (or extract) the package:
    dpkg -i opencode_1.18.21_aarch64.deb

  3. Run OpenCode:
    opencode --version

Result:
Bad system call ./opencode --version
exit code: 159

Also reproduced by extracting the .deb with dpkg-deb -x and
running the unpacked binary directly (same SIGSYS crash).


  1. EXPECTED BEHAVIOR

  • opencode --version should print "1.18.21" and exit 0.
  • The full CLI (TUI, models list, agent list) should start normally.

  1. ACTUAL BEHAVIOR / OBSERVED SYMPTOMS

  • Every startup attempt ends with SIGSYS "Bad system call"
    (exit 159), before any output is produced.
  • Symptom is consistent (not intermittent) - 3/3 runs crashed.

  1. DIAGNOSIS / ROOT-CAUSE HYPOTHESIS

SIGSYS / "Bad system call" occurs when a process invokes a syscall
that the kernel does not implement or the seccomp policy blocks.

Since API level (30) satisfies the documented ">= 28" requirement,
the most probable cause is that the native binary invokes a newer
syscall (e.g. faccessat2, openat2, clone3, or similar) that
the older 4.19.152 kernel on this device does not provide.

The corresponding glibc build (opencode-glibc 1.18.15) runs fine on
the exact same device, which strongly suggests the difference is in
how the native binary interacts with the kernel/syscalls rather than
a generic incompatibility with the device.


  1. IMPACT

  • The "native bionic mainline" build (which the release notes mark as
    the recommended mainline going forward) cannot be used on this
    device.
  • Users on older Android 11 / kernel 4.19 devices are forced back to
    the now-legacy glibc wrapper line (1.18.15), which caps their
    OpenCode version at 1.18.15.

  1. REQUESTED ACTION / QUESTION

  1. Is there a known kernel/API requirement (beyond "API >= 28") for the
    native build, e.g. a specific minimum kernel version, or a specific
    set of syscalls that must be available?
  2. Would it be possible to either:
    a) fall back to older syscalls (or use syscall(SYS_* ) shims)
    for kernels < 5.x, or
    b) publish the glibc line at the same version (1.18.21) so users
    on older kernels are not stuck at 1.18.15?

  1. ADDITIONAL INFO

  • Checksum (sha256) of the tested asset, verified against
    SHA256SUMS.txt:
    opencode_1.18.21_aarch64.deb
    = 3bc040e95b49da085fe280e08b46558df5839d1d06ab5304c45ac98cf2508e76
  • The native binary is an aarch64 bionic ELF; the static string
    "/lib64/ld-linux-x86-64.so.2" present in the file belongs to the
    bundled OpenSSL and is NOT the binary interpreter (the binary is
    genuinely aarch64).
  • strace is not available on this Termux environment and the kernel
    logs (dmesg) are not readable without root, so the exact offending
    syscall number could not be captured on-device.

================================================================
END OF REPORT

Activity

  1. Hope2333 commented on Sep 3, 2026

    @Hope2333
    Owner

    Thanks for the thorough report — your diagnosis is correct.

    Root cause: Android's zygote seccomp filter (API ≤ 14 / kernel 4.19) does not include close_range (syscall nr 436) in its allow-list. When Bun calls close_range(4, ~0U, CLOSE_RANGE_CLOEXEC) during startup fd hygiene, the kernel delivers SECCOMP_RET_TRAP → SIGSYS (exit 159). This is the same root cause as upstream oven-sh/bun#30766, first reported on Android 12 / SDK 31.

    What RC1 fixes: The Push260903rc1 native package ships libopencode-crhandler.so — a self-activating seccomp rescue layer with two complementary mechanisms:

    1. SIGSYS handler (SA_SIGINFO): intercepts the signal at delivery time, advances the program counter past the trapping svc instruction (pc += 4), and returns -ENOSYS in x0. This covers inline-svc sites that no PLT interposition can reach (same semantics as upstream #39775 / #39060).

    2. PLT interposers for syscall() and close_range(): short-circuit nr 436 at call sites before the kernel ever sees it. This is the only layer that rescues bun's forked child processes, which inherit no usable SIGSYS disposition.

    The shim is wired as the first DT_NEEDED entry in the binary's dynamic section via tools/transplant/crhandler_patch.py — bionic's symbol lookup order means the PLT interposition wins over libc. No LD_PRELOAD, no environment variables, no user action required.

    Immediate fallback (if you want to test before RC1): The earlier native-beta-260826 release provides a standalone LD_PRELOAD shim (libopencode-crshim.so, PLT-only, no handler layer):

    curl -fsSL https://github.com/Hope2333/opencode-termux/releases/download/native-beta-260826/libopencode-crshim.so -o $PREFIX/lib/libopencode-crshim.so
    export LD_PRELOAD=$PREFIX/lib/libopencode-crshim.so

    Note: this older shim only covers PLT call sites — bun's spawn-child path (inline svc) may still SIGSYS. The RC1 crhandler covers both layers.

    Please test RC1:

    # https://github.com/Hope2333/opencode-termux/releases/tag/Push260903rc1
    # Asset: opencode_1.18.21_aarch64.deb (native, with crhandler shim)
    dpkg -i opencode_1.18.21_aarch64.deb
    opencode --version

    To help us close this issue, please report:

    1. Your Android version (you mentioned API 30 — confirmed Android 11)
    2. Whether RC1 native resolves the SIGSYS crash

    If it still fails, please share the output and we'll investigate further.

  2. mozzaru commented on Sep 4, 2026

    @mozzaru
    Author

    ========================================
    OPENCODE NATIVE RC2 - TEST REPORT

    Date: 2026-09-04
    Tester: User (Termux)
    Package: opencode_1.18.27_aarch64.deb (native, RC2)


    DEVICE INFORMATION

    Platform: aarch64
    Android Version: 11
    API Level: 30
    Kernel: (Termux environment)


    TEST RESULT: SUCCESS

    Command: opencode --version
    Output: 1.18.27
    Status: No SIGSYS crash, no SECCOMP_TRAP, no exit 159


    ANALYSIS

    Root Cause (before fix):
    Android's zygote seccomp filter (API <= 14 / kernel 4.19)
    does not include close_range (syscall nr 436) in its allow-list.
    When Bun calls close_range(4, ~0U, CLOSE_RANGE_CLOEXEC) during
    startup fd hygiene, the kernel delivers SECCOMP_RET_TRAP -> SIGSYS
    (exit 159).

    What RC2 Fixes:
    The native package ships libopencode-crhandler.so — a self-activating
    seccomp rescue layer with two complementary mechanisms:

    1. SIGSYS handler (SA_SIGINFO): intercepts the signal at delivery
      time, advances the program counter past the trapping svc
      instruction (pc += 4), and returns -ENOSYS in x0.

    2. PLT interposers for syscall() and close_range(): short-circuits
      nr 436 at call sites before the kernel ever sees it.

    The shim is wired as the first DT_NEEDED entry in the binary's
    dynamic section. No LD_PRELOAD, no environment variables,
    no user action required.


    VERDICT

    [PASS] opencode native RC2 works on Android 11 / API 30
    [PASS] SIGSYS crash resolved
    [PASS] No manual configuration needed

    ========================================
    END OF REPORT

  3. mozzaru commented on Sep 4, 2026

    @mozzaru
    Author
  4. mozzaru commented on Sep 4, 2026

    @mozzaru
    Author

    Crash ?
    ???:?:?: 0x5de3484893 in ??? (/data/data/com.termux/files/usr/bin/opencode) ???:?:?: 0x5de300a12f in ??? (/data/data/com.termux/files/usr/bin/opencode)
    ???:?:?: 0x5de3008c63 in ??? (/data/data/com.termux/files/usr/bin/opencode)
    ???:?:?: 0x5de28925e3 in ??? (/data/data/com.termux/files/usr/bin/opencode) ???:?:?: 0x5de2897b4b in ??? (/data/data/com.termux/files/usr/bin/opencode) ???:?:?: 0x5de2f79fdb in ??? (/data/data/com.termux/files/usr/bin/opencode)
    ???:?:?: 0x5de2ef51c7 in ??? (/data/data/com.termux/files/usr/bin/opencode)
    ???:?:?: 0x5de2ef2fc7 in ??? (/data/data/com.termux/files/usr/bin/opencode)
    ???:?:?: 0x5de21a9e8b in ??? (/data/data/com.termux/files/usr/bin/opencode) ???:?:?: 0x71a0ef3a5f in ??? (/apex/com.android.runtime/lib64/bionic/libc.so) ???:?:?: 0x5de21a986b in ??? (/data/data/com.termux/files/usr/bin/opencode)
    Aborted

    Deterministic SIGABRT crash on pure-android branch — likely TLS/Scudo heap corruption, not pointer-tagging

    Environment

    • Branch: pure-android
    • Device: Android (Bionic libc, /system/bin/linker64 interpreter)
    • Binary: opencode (glibc ELF wrapped via bun-termux-loader, userland-exec)
    • Dependencies installed: glibc, openssl-glibc (per README instructions)

    Symptom

    opencode crashes with Aborted after a short period of use (not immediately on
    startup). The crash is fully deterministic — repeated runs abort at the exact
    same relative code offset every time, only shifted by ASLR.

    Investigation performed

    1. Captured native stack traces across multiple crash occurrences. Verified via
      offset diffing (subtracting the lowest frame address from each frame) that all
      frames match exactly across separate runs — confirming a deterministic bug,
      not memory corruption from an unrelated random source.

    2. Attached gdb (gdb -q --args opencode, run, thread apply all bt) at the
      moment of SIGABRT. Findings:

      • Most background threads (Helper/HeapHelper/JITWorker/Bun Pool/etc.) are idle,
        parked in epoll_pwait — normal, not the crash site.
      • Thread 1 ("opencode", main thread) is the actual crash site:
        Thread 1 (Thread 0x7bf8 (LWP 31736) "opencode"):
        #0  0x0000007f07b9307c in ?? ()
        #1  0xfffe000000000002 in ?? ()
        Backtrace stopped: previous frame identical to this frame (corrupt stack?)
        
      • $pc for the crashing frame does not land in the opencode binary's
        .text segment (r-xp mapping of /data/data/com.termux/files/usr/bin/opencode).
        It lands inside anonymous heap memory (in the mimalloc/heap allocator
        address range per /proc/<pid>/maps).
      • Frame 安装后尝试运行显示Segmentation fault #1 contains 0xfffe000000000002 — not a valid pointer. This bit
        pattern is consistent with a truncated/corrupted tagged pointer, i.e.
        the classic Bionic "software heap tagging" tag-mismatch symptom (see
        https://source.android.com/devices/tech/debug/tagged-pointers), OR
        Scudo allocator metadata corruption from a TLS layout mismatch.
    3. Tested JSC_useJIT=0 — no change, crash identical (ruled out JIT-codegen
      as the direct cause, though JS engine's use of JIT/heap layout may still be
      an indirect factor).

    4. Tested LD_PRELOAD=libtagfix.so (binary pulled from
      guysoft/opencode-termux v0.2.1 release asset) — loaded successfully, no
      linker errors, but crash is byte-for-byte identical
      (verified via offset
      diff against the pre-preload crash). This strongly suggests the root cause
      is not simply Bionic's pointer-tagging tag-mismatch (which libtagfix.so
      is designed to suppress by disabling heap tagging via
      mallopt(M_BIONIC_SET_HEAP_TAGGING_LEVEL, ...) before JSC init) — because
      that specific mitigation had zero effect on this binary.

    Hypothesis

    guysoft/opencode-termux's README documents a TLS alignment fix required
    for any Bun binary running under Bionic:

    Without this, the Zig linker emits PT_TLS p_align=8, causing TLS variables
    to overlap with Bionic's Thread Control Block slots (TPIDR+0..63),
    corrupting scudo allocator state and crashing on first allocation.

    This branch (pure-android) does not cross-compile Bun for Android — it wraps
    the unmodified upstream glibc-linked Bun binary via bun-termux-loader's
    userland-exec. If the TLS section layout emitted for the glibc target doesn't
    align correctly once the binary is running under Bionic's threading/TCB
    implementation (via the userland-exec trick), this could produce exactly the
    kind of Scudo/heap corruption I'm observing — independent of Bionic's
    pointer-tagging feature, which is why libtagfix.so had no effect.

    Ask

    • Is TLS segment alignment/layout something bun-termux-loader's userland-exec
      accounts for when jumping into glibc's ld.so? If not, this may be the
      actual root cause rather than pointer-tagging.
    • Given libtagfix.so doesn't help here, is there a known workaround, or is
      this fundamentally a limitation of the "wrap unmodified upstream binary"
      approach vs. guysoft's "cross-compile Bun natively for Android" approach
      (which patches this at the Zig/CMake build level)?

    Reproduction data available on request

    • Full /proc/<pid>/maps dump at crash time
    • gdb thread apply all bt output (all 25 threads)
    • Disassembly around crash offset in libc.so (confirmed as an
      __epoll_pwait-adjacent idle thread, unrelated to the actual crash — the
      real crash site is in Thread 1 as noted above)
    • Offset-diff script confirming deterministic crash location across runs
  5. Hope2333 commented on Sep 5, 2026

    @Hope2333
    Owner

    Thank you — this report is exceptionally high quality. The gdb attach, the multi-run offset diffing, the libtagfix.so control experiment, the JIT exclusion… that is textbook-grade on-device forensics, and we genuinely appreciate the time you put into it.

    A quick status sync — your reports all landed on issues we independently found and fixed during our own RC stage:

    1. SIGSYS (close_range / seccomp): your diagnosis matches ours exactly. During RC we reproduced it ourselves and shipped a dual-layer fix (the self-activating libopencode-crhandler.so shim + DT_NEEDED[0] hardening). It is now included in the formal release Push260906 (v1.18.15-26 v1.18.27, current Latest) across all 13 versions. Your RC2 retest (1.18.27 passing, no SIGSYS) matches our own on-device verification — thanks again for that.

    2. Deterministic SIGABRT / TLS alignment on the wrapped (pure-android) line: your TLS-alignment hypothesis was directionally spot-on — and it is exactly the architectural question that drove our RC-stage decision: the bun-termux-loader wrap path (unmodified upstream glibc binary via userland-exec) is now demoted to appendix maintenance and is no longer the mainline. The mainline is the native bionic revived line (direct ELF surgery, no userland-exec wrapper at all), and the glibc appendix was recast as a self-contained composite that no longer requires the system glibc / openssl-glibc packages (the two deps you installed per the old README can be uninstalled). On the Push260906 mainline packages, this crash path should be gone entirely.

    3. oh-my-openagent: yes, it works — we use it in our current workflow. Recommended install: the opencode plugin command (verified working on both runtime lines — the native mainline and the glibc appendix); after install, let the agent configure it according to the docs (docs/plugin-management.md). Local file:// registration still works as a fallback, but the plugin command is the better-managed path. Install/migration guide for the release itself: docs/dual-track-install.md.

    If you feel like doing one more round on the formal release: your repro data (the maps dump, the full gdb bt, the offset-diff script) is exactly the kind of real-device evidence we lack — if anything still reproduces on Push260906, please keep posting in this format and we will follow up. Thanks again for reports of this caliber — they are very welcome here.

  6. mozzaru commented on Sep 6, 2026

    @mozzaru
    Author

    besides oh-my-openagent
    What plugin or harness is good for review, refactor, debug??

    The problem is using oh-my-openagent, if you use a custom provider like glm-5.3-flash, the Oracle review error

  7. Hope2333 commented on Sep 7, 2026

    @Hope2333
    Owner

    Plugins/harness for review / refactor / debug:

    oh-my-openagent (OMO) is the harness we use for exactly those workflows — no extra plugin needed:

    • Review: OMO's oracle agent (read-only, high-quality reasoning consultant) plus the sisyphus orchestrator cover architecture review and post-change review.
    • Refactor / debug: oracle for root-cause analysis and design tradeoffs, parallel explore agents for codebase reconnaissance, execution agents (hephaestus/atlas) for carrying out the change.

    On the Oracle error with a custom provider (glm-5.3-flash):

    That's a model-tier mismatch, not an OMO bug. Oracle's prompts are long (full-file context + review rubric) and reasoning-heavy; flash-tier models like glm-5.3-flash often fail or degrade on them. OMO supports per-agent model assignment in ~/.config/opencode/oh-my-openagent.json:

    {
      "agents": {
        "oracle": {
          "model": "<strong-reasoning-model-id>",
          "fallback_models": ["<second-strong-model-id>"]
        },
        "explore": {
          "model": "<flash-model-id>"
        }
      }
    }

    That's the split we run ourselves: strong models on oracle/sisyphus (quality tier), flash models on explore/librarian/execution agents (throughput tier). Keep glm-5.3-flash for retrieval/execution work and give oracle the strongest model your provider offers. If it still errors with a strong model, check the provider's context-limit settings in opencode.json — Oracle's context is large and some custom providers reject it.

  8. mozzaru commented on Sep 7, 2026

    @mozzaru
    Author

    I did a review just asking for Oracle, and the results seemed like the reviewer was not late, there were assumptions, so I was confused about using the free model and the results were like that

    Do you always review full reviews??

    Kan oracle for review, then sisyphus For others so

    For example, asking for a review or consultation from Oracle, that's what I do,

    Btw is there a good free model??
    hehe🗿

  9. Hope2333 commented on Sep 26, 2026

    @Hope2333
    Owner

    Status: the SIGSYS crash you diagnosed is fixed and shipped — please verify.

    The fix is exactly the mechanism you reverse-engineered: close_range (and friends) hitting seccomp SIGSYS on older Android kernels. We now ship a self-activating shim:

    • tools/shim/sigsys_handler.c → libopencode-crhandler.so, linked into the binary as DT_NEEDED by the seccomp-harden step of the build chain (pre-patch copy kept as *.pre-crhandler for rollback).
    • It ships at usr/lib/opencode/libopencode-crhandler.so (matching the binary's DT_RUNPATH $ORIGIN/../lib/opencode) in opencode1 1.18.32 on the current release (Push260922) — today's rebuild also carries the Bun 1.4.0 fix from [1.18.32] Bun 1.4.2 segfault at 0x40 on Android/bionic #23.

    To verify on your kernel: pacman -S opencode1 (or dpkg -i opencode1_1.18.32_aarch64.deb), then confirm the shim is present and the binary references it:

    pacman -Ql opencode1 | grep crhandler      # usr/lib/opencode/libopencode-crhandler.so
    readelf -d $(command -v opencode1) | grep -E 'NEEDED.*crhandler|RUNPATH'
    opencode1 --version

    then run your previously-crashing workflow. If the SIGSYS crash still reproduces with the shim loaded, please reopen with the new log — that would mean the syscall being trapped isn't one the handler covers.

    (On the side thread: for review/refactor/debug workflows OMO's oracle agent is the reviewer; quality varies with the backing model — see https://opencode.ai/docs if you want to swap providers.)

  10. Hope2333 commented on Sep 26, 2026

    @Hope2333
    Owner

    Fixed in opencode1 1.18.32 — the seccomp shim (libopencode-crhandler.so) now ships with the package. Please verify with the steps in the comment above and reopen if the SIGSYS crash persists.

  11. mozzaru commented on Sep 27, 2026

    @mozzaru
    Author

    oot: you use opencode v1 or v2
    Recommended combo ?
    Let's review code, refactor, debug, fix code, no hallucinations, guesses, or assumptions.

    ??

  12. Hope2333 commented on Sep 28, 2026

    @Hope2333
    Owner

    RC3 (Push260922, 2026-09-28) supersedes the Push260828-era build — the whole two-generation family was rebuilt with bun 1.4.0 embedded (the 1.4.2 runtime was the crash source, see #23) and re-uploaded with PKGREL=3:

    • v1 opencode1* 1.18.30–1.18.32 (native / wrapper / compressed)
    • v2 opencode / opencode-wrapper 2.0.0–2.0.12

    Please upgrade to the latest:

    pacman -S opencode1            # v1 mainline
    pacman -S opencode             # v2 mainline (coexists with v1)

    or direct assets: https://github.com/Hope2333/opencode-termux/releases/tag/Push260922

    ⚠ One note: your report is on kernel 4.19 (Android 11) — same environment as #24. If Bad system call (SIGSYS) still occurs on an RC3 build (pacman pkgrel -3), please share uname -a and we'll investigate the seccomp-shim angle on older kernels specifically.

  13. mozzaru commented on Sep 28, 2026

    @mozzaru
    Author

    @Hope2333
    Update on kernel 4.19.152 (Android 11, Termux, aarch64):

    • opencode1 1.18.32-3: works, shim present at $PREFIX/lib/opencode/libopencode-crhandler.so. Thanks, verified.
    • opencode 2.0.12-3 (v2 native): the package contains only usr/bin/opencode and no libopencode-crhandler.so. It crashes with SIGSYS ("Bad system call", exit=159).
    • However, preloading the v1 shim makes it work:
      LD_PRELOAD=$PREFIX/lib/opencode/libopencode-crhandler.so opencode --version
      -> opencode v2.0.12, exit=0

    So the v2 native build seems to only need the same seccomp shim. Could you ship libopencode-crhandler.so (and the DT_NEEDED link via the seccomp-harden step) in the v2 opencode packages as well?

    Also a packaging note: pacman -U on these packages tries to write to /usr instead of the Termux prefix, so I extract manually with tar -xJf -C $PREFIX --strip-components=1 usr.

    Happy to test any v2 build.

  14. Hope2333 commented on Sep 28, 2026

    @Hope2333
    Owner

    Excellent debugging — the LD_PRELOAD test is the smoking gun. Thanks for the verified matrix. 🙏

    Root cause confirmed

    You're right. The v2 native chain (family-v2-native → build-native → deb-native/pacman-native) never runs the harden-native step (only the compressed chain does), and the native packagers don't ship libopencode-crhandler.so. So v2 native packages contain only usr/bin/opencode:

    • kernel ≥5.x devices: fine (the syscalls the shim handles don't trip Android's own seccomp policy)
    • kernel 4.19 (your case): a syscall gets SIGSYS-killed → Bad system call, and the v1 shim fixes it because it ships exactly that handler

    Fix plan

    1. Wire harden-native into family-v2-native (same zero-displacement crhandler chain the v1/compressed line uses)
    2. Ship libopencode-crhandler.so in deb-native / pacman-native (v1-style layout: lib/opencode/ + DT_RUNPATH), so --version works with no preload
    3. Rebuild + re-upload the v2 native shelf assets (0.2.[0-12] + 2.0.18 already built locally)

    I'll ping this issue when the rebuilt -4 assets are on the shelf — your kernel-4.19 device is the perfect canary. 🙂

    On the pacman /usr note

    Interesting — on our reference device pacman -U of the same package installs into the Termux prefix correctly and opencode lands on PATH (2.0.18-1 verified today). Could you share the output of:

    pacman --version
    pacman-conf | grep -E 'RootDir|DBPath|CacheDir'

    So we can pin down whether your pacman root differs (we may also switch the payload to prefix-direct paths if that's the more compatible layout across pacman variants).

    Meanwhile the LD_PRELOAD workaround is fully functional. Thanks again — this report materially improved the packaging line.

  15. mozzaru commented on Sep 28, 2026

    @mozzaru
    Author

    @Hope2333
    Thanks for the quick fix plan, glad the LD_PRELOAD test helped. Happy to canary the -4 assets on kernel 4.19.

    Here is my pacman info:

    $ pacman --version
    Pacman v7.1.0 - libalpm v16.0.0

    $ pacman-conf | grep -E 'RootDir|DBPath|CacheDir'
    RootDir = /
    DBPath = /data/data/com.termux/files/usr/var/lib/pacman/
    CacheDir = /data/data/com.termux/files/usr/var/cache/pacman/pkg/

    $PREFIX/etc/pacman.conf has these lines commented out, so these are the defaults.

    So on my device RootDir is /, which explains the earlier behaviour: the payload's usr/bin/opencode is extracted to /usr/bin/opencode (read-only on Android), and pacman printed "Can't create '/usr'" while still reporting the package as installed. For RootDir = /, a prefix-direct payload (data/data/com.termux/files/usr/...) would be the compatible layout, as far as I can tell. If your reference device uses a different RootDir, that would explain why it works there.

  16. Hope2333 commented on Sep 28, 2026

    @Hope2333
    Owner

    Update on the pacman /usr note — root cause confirmed via a reproduction on our experiment device (kernel 3.18.140, MoKee):

    Root cause: RootDir in pacman.conf

    Our packages carry payload paths relative to the Termux root (usr/bin/opencode → lands in $PREFIX/bin). On a working setup:

    RootDir = /data/data/com.termux/files
    

    On devices where install works "into /usr", pacman.conf has RootDir commented out (#RootDir = /) or absent — alpm then falls back to its compiled default /, and the transaction tries to write the read-only Android rootfs (Partition / is mounted read only + not enough free disk space).

    Two more traps on the same machines (both hit during reproduction):

    1. If RootDir is set but DBPath is absent, that pacman build joins its compiled default dbpath onto RootDir → doubled path → failed to initialize alpm library.
    2. pacman.d/hooks/ and pacman.d/gnupg/ directories must exist, or pacman.conf parsing fails outright.

    One-line client fix

    sed -i 's|^#\?RootDir.*|RootDir = /data/data/com.termux/files|' /data/data/com.termux/files/usr/etc/pacman.conf
    mkdir -p /data/data/com.termux/files/usr/etc/pacman.d/{hooks,gnupg}

    (If your DBPath line is also missing, add DBPath = /data/data/com.termux/files/usr/var/lib/pacman/.)

    Shipped fix

    Our source-setup script now self-heals all three cases automatically (uncomment/insert RootDir, add the DBPath block, create the dirs) — so install.sh users won't hit this.

    Side evidence

    After the fix, pacman -U of opencode-2.0.12-3 succeeded on that device and opencode --version reports v2.0.12 fine on kernel 3.18 — so the SIGSYS class you hit on 4.19 is specific to certain kernel/seccomp combinations, not universal. The PKGREL=4 rebuild with the seccomp shim shipped (in progress, see my earlier comment) is targeted exactly at that class — I'll ping when it's on the shelf so you can retest on your 4.19 device.

  17. Hope2333 commented on Sep 29, 2026

    @Hope2333
    Owner

    @mozzaru RC4 (Push260928) 已全量上架:v2 native 全线 PKGREL=4(seccomp shim 随包,修 #17/#24 老内核 SIGSYS)+ PTY musl 静态助手(修 #27),19 版 2.0.0-2.0.18 + v1 1.18.30-33,96 件逐件 digest 对账。请在你 4.19 设备上复测 pacman -S opencode(或直链 opencode-2.0.18-4-aarch64.pkg.tar.xz),若仍见 Bad system call 请贴 uname -a。另外 pacman RootDir 修复已进 install.sh 自愈(见上条评论)。

  18. mozzaru commented on Sep 29, 2026

    @mozzaru
    Author

    @Hope2333
    Ran a clean install test on my kernel 4.19.152 device (Android 11, Termux, aarch64) to fully verify RC4 end to end.

    Steps

    1. Removed all previous opencode/opencode1 binaries, shim, config/data dirs, and downloaded packages (fresh state).
    2. Ran the official one-liner:
      curl -fsSL https://hope2333.github.io/repo/install.sh | sh -s -- --install opencode

    Result A — source script

    • RootDir self-heal worked ("RootDir 自检通过").
    • pacman database sync partially failed: main/x11/tur-continuous etc. could not reach service.termux-pacman.dev from my network (connection timeout), though the hope2333 repo db itself synced fine.
    • hope2333-mirrorlist then failed with a checksum mismatch on every retry (re-downloaded fresh each time, not a cached-file issue), so pacman -S opencode never got to run.
    • This looks environment/network related on the termux-pacman.dev side, but the mirrorlist checksum failure repeated identically across multiple attempts and may be worth a look independently.

    Result B — manual package install (fallback)

    • Downloaded opencode-2.0.18-4-aarch64.pkg.tar.xz directly.
    • Package now correctly ships usr/lib/opencode/libopencode-crhandler.so (confirmed via tar -tf).
    • pacman -U extracted the payload correctly this time (RootDir fix works, no more "Can't create '/usr'").
    • However the post-install hook failed:
      /data/data/com.termux/files/usr/bin/bash: line 1: /usr/tmp/alpm_qs2HTL/.INSTALL: No such file or directory
      /data/data/com.termux/files/usr/bin/bash: line 1: post_install: command not found
      error: command failed to execute correctly
    • Despite the hook error, the binary and shim were both extracted correctly (verified with ls), and functionally everything works:
      opencode --version -> opencode v2.0.18, exit=0
    • No SIGSYS, no LD_PRELOAD needed. This confirms the PKGREL=4 shim fix works for the native v2 line on kernel 4.19.

    Summary

    • Core fix (seccomp shim in v2 native): confirmed working end to end on a clean install.
    • Two smaller packaging issues found during the clean-install path:
      1. .INSTALL hook script appears to reference a hardcoded /usr/tmp/... path instead of the Termux prefix, so post_install never runs (though it doesn't block basic usage).
      2. hope2333-mirrorlist package fails pacman's checksum check on fresh download (reproduced 2x), independent of the termux-pacman.dev connectivity issue.

    Happy to test fixes for either. Will follow up with a TUI soak test result separately.

  19. mozzaru commented on Sep 29, 2026

    @mozzaru
    Author

    @Hope2333
    Ran a second clean-install cycle on kernel 4.19.152 (Android 11, Termux, aarch64) — this time via the official pacman path instead of manual -U, to cross-check the earlier report.

    1. Uninstalled cleanly first (pacman -R opencode). Note: pacman -R reported success and removed the DB entry, but left the binary on disk at $PREFIX/bin/opencode — had to rm it manually before retesting. Might want to check whether a pre_remove/post_remove hook is silently failing the same way .INSTALL does on install.

    2. Ran the official one-liner:
      curl -fsSL https://hope2333.github.io/repo/install.sh | sh -s -- --install opencode

      • RootDir self-heal worked again ("RootDir 自检通过").
      • hope2333-mirrorlist-1.0.20260928-1 failed pacman's checksum check again — this is the second time I've hit this exact failure, same package version, different session/network state. Re-downloaded fresh both times (3.1 KiB, not a stale cache), so this looks like a real checksum/package mismatch on the hope2333 repo db itself, not a network fluke on my end.
      • Script's own error path caught it correctly and told me to configure manually, which is good UX, but pacman -S opencode still never ran through the script.
    3. Ran pacman -S opencode directly (repo db was already synced from step 2):

      • Installed successfully via the official resolver path (not manual -U this time).
      • Same .INSTALL hook failure as before, reproduced exactly:
        /data/data/com.termux/files/usr/bin/bash: line 1: /usr/tmp/alpm_2UPkCt/.INSTALL: No such file or directory
        /data/data/com.termux/files/usr/bin/bash: line 1: post_install: command not found
        error: command failed to execute correctly
      • Despite the hook error, everything works correctly:
        pacman -Qi opencode -> Version: 2.0.18-4
        opencode --version -> opencode v2.0.18, exit=0
        libopencode-crhandler.so present at $PREFIX/lib/opencode/

    Summary

    • Core fix confirmed solid across two independent clean installs (manual -U and pacman -S): no SIGSYS on kernel 4.19, shim present and working.
    • Two packaging bugs are now reproducible 2/2:
      1. hope2333-mirrorlist checksum failure on fresh download (same version both times)
      2. .INSTALL hook hardcodes /usr/tmp/... instead of the Termux prefix's tmp dir, so post_install never runs on install — and possibly the mirror hook (pre/post_remove) on removal too, since pacman -R left the binary behind despite reporting a clean removal.

    Neither bug blocks basic usage, but the .INSTALL failure means whatever post_install is supposed to do (config migration? symlinks?) silently never happens, and the removal issue could leave stale binaries after upgrades. Happy to test fixes.

  20. Hope2333 commented on Sep 29, 2026

    @Hope2333
    Owner

    Both packaging bugs confirmed and triaged — thanks for the 2/2 reproductions, exactly what we needed.

    Core fix: confirmed ✅

    Two independent clean installs on kernel 4.19 with zero SIGSYS — the seccomp shim ships and works. (And your RootDir self-heal log confirms the install.sh fix is doing its job.)

    Bug A — hope2333-mirrorlist checksum mismatch: root cause found

    Our pacman Server URLs resolve via releases/latest/download/ — and "latest" moved to RC4 (Push260928) mid-window. The hope2333-mirrorlist-1.0.20260928-1 package and the hope2333.db you downloaded came from different site-rebuild self-heal runs (non-atomic pair upload during the latest-pointer transition). Verified just now on the current shelf: db-recorded %SHA256SUM% = 7ec10039… == served package sha256 — the pair has since converged, which is why it's intermittent.

    Fix in progress: site-rebuild will upload the db+pkg pair atomically on every change. Interim workaround: retry the source setup after a few minutes, or pin the direct asset URL.

    Bug B — .INSTALL hook /usr/tmp: known termux-pacman limitation, mitigation planned

    libalpm extracts install/remove hook scripts into its transaction temp dir, which on your build resolves to /usr/tmp — non-existent/read-only on Android, so post_install/pre_remove/post_remove never run. That also explains your pacman -R leftover (the removal hook that would clean $PREFIX/bin/opencode silently failed).

    Mitigation plan (RC5 packaging round):

    1. Move critical install-time logic (stale-serve cleanup) from .INSTALL to pacman hook files shipped under the package's hook dir — those run from HookDir (a real path), not alpm's tmp
    2. Document .INSTALL as best-effort on termux-pacman builds
    3. pacman -R users: rm -f $PREFIX/bin/opencode after removal until the hook lands

    Happy to have you retest RC5 when it ships — your 4.19 device is our canary for exactly this class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions