Skip to content

[Bug]: x86_64 Bun/OpenCode TUI aborts in tb_remove_from_jmp_list on LoongArch LSX/no-LASX #324

Description

@TOA-HI

Bug Description / 错误描述

Running an x86_64 Bun/OpenCode standalone binary through LATX on LoongArch64 can crash in the interactive TUI path.

Observed failure 1: when the full TUI is running, pressing Ctrl-C / exiting can abort inside LATX/QEMU TCG code:

ERROR:../accel/tcg/translate-all.c:1777:tb_remove_from_jmp_list: code should not be reached
Bail out! ERROR:../accel/tcg/translate-all.c:1777:tb_remove_from_jmp_list: code should not be reached

Observed failure 2: after a bad TUI exit or stale generated translation state, launching the same program with a fixed port can fail with:

not found LASX, use 128-bit vectors
Invalid value for lock: 0
Aborted (core dumped)

This appears related to LATX translated-code / parallel translation / generated cache state. Setting LATX_CLOSE_PARALLEL=1 avoids the tb_remove_from_jmp_list abort for the TUI exit path, but the translated TUI remains fragile after bad exits.

Environment Information / 环境信息

操作系统: AOSC OS 13.3.0,LoongArch64
Linux 内核版本: Linux 7.0.13-aosc-main-16k
GCC 版本: GCC 15.3.0
GLIBC 版本: glibc 2.42
LAT 版本号 / 提交 Hash: lat-x86_64 9bd2f78

Additional environment details:

  • CPU: Loongson 2K3000
  • Architecture: loongarch64
  • Kernel page size: 16 KiB (getconf PAGESIZE => 16384)
  • CPU features include: lsx, lbt_x86
  • CPU does not have LASX
  • LATX runtime output:
not found LASX, use 128-bit vectors
lat-x86_64 9bd2f78

x86_64 userspace: AOSC emukit 20240730
Node.js on host: v24.17.0
Bun guest/runtime used by tested software: bun-linux-x64-baseline 1.3.14

Steps to Reproduce / 重现步骤

  1. Build LATX x86_64 on a LoongArch64 machine without LASX but with LSX + LBT_X86.
  2. Install AOSC emukit so x86_64 userspace exists.
  3. Build or obtain an x86_64 Linux baseline Bun/OpenCode standalone executable.
  4. Run the OpenCode TUI through LATX:
/usr/local/bin/latx-x86_64 ./opencode-linux-x64-baseline/bin/opencode
  1. Wait for the TUI to draw.
  2. Press Ctrl-C or exit the TUI.

Observed abort:

ERROR:../accel/tcg/translate-all.c:1777:tb_remove_from_jmp_list: code should not be reached

A second related failure was observed after bad exits / stale translated state:

/usr/local/bin/latx-x86_64 ./opencode-linux-x64-baseline/bin/opencode --port 26701

Observed:

not found LASX, use 128-bit vectors
Invalid value for lock: 0
Aborted (core dumped)

Killing leftover LATX processes and clearing generated LATX cache can recover this second state:

killall -q latx-x86_64 || true
rm -f ~/.cache/latx/*opencode* ~/.cache/latx/*bun*

Software Information:

Software: OpenCode CLI
OpenCode source tag: v1.17.13
OpenCode source commit: 10c894bdeef3618f5666fb506ef7f9491bb964d8
Built target: Linux x64 baseline standalone binary
Build runtime: Bun 1.3.14, bun-linux-x64-baseline
OpenCode local build reports version: 0.0.0--202607060634
LATX command used:

/usr/local/bin/latx-x86_64 ./opencode-linux-x64-base

Expected Behavior / 预期行为

The x86_64 guest program should run and exit normally through LATX.

Specifically:

  • Pressing Ctrl-C or exiting the OpenCode TUI should terminate cleanly.
  • LATX should not abort in tb_remove_from_jmp_list.
  • Relaunching the same guest program with --port should not fail with Invalid value for lock: 0.

Actual Behavior / 实际行为

The translated program can abort during TUI exit:

ERROR:../accel/tcg/translate-all.c:1777:tb_remove_from_jmp_list: code should not be reached
Bail out! ERROR:../accel/tcg/translate-all.c:1777:tb_remove_from_jmp_list: code should not be reached

After a bad exit or stale translated state, a later run can also fail with:

not found LASX, use 128-bit vectors
Invalid value for lock: 0
Aborted (core dumped)

A workaround was found for the first failure:

export LATX_CLOSE_PARALLEL=1

With that environment variable, the TUI exit path no longer triggered the tb_remove_from_jmp_list assertion in my testing.

However, the translated TUI / --port path still appears fragile after bad exits and may require clearing the generated LATX cache.

Screenshots or Logs / 截图或日志

Relevant logs:

not found LASX, use 128-bit vectors
ERROR:../accel/tcg/translate-all.c:1777:tb_remove_from_jmp_list: code should not be reached
Bail out! ERROR:../accel/tcg/translate-all.c:1777:tb_remove_from_jmp_list: code should not be reached

Severity / 严重性

Medium / 中

Additional Information / 附加信息

Notes:

  • This machine has LSX and LBT_X86 but not LASX.
  • LATX prints not found LASX, use 128-bit vectors, so this is testing the LSX fallback path.
  • The failure is not caused by vanilla QEMU binfmt selection; x86_64 binfmt was configured to use /usr/local/bin/latx-x86_64.
  • The string Invalid value for lock: appears in the Bun/OpenCode executable, not in the LATX executable, but the failure state appeared only while running the x86_64 binary through LATX.
  • Clearing generated LATX cache with the following command allowed the --port launch to work again during testing:
killall -q latx-x86_64 || true
rm -f ~/.cache/latx/*opencode* ~/.cache/latx/*bun*

LATX_CLOSE_PARALLEL=1 avoided the tb_remove_from_jmp_list abort on TUI exit in testing.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions