Skip to content

LATX, fix: Reclaim guest thread and seccomp ownership resources - #472

Open
LaurenIsACoder wants to merge 1 commit into
lat-opensource:masterfrom
LaurenIsACoder:latx-memory-cleanup-draft
Open

LATX, fix: Reclaim guest thread and seccomp ownership resources#472
LaurenIsACoder wants to merge 1 commit into
lat-opensource:masterfrom
LaurenIsACoder:latx-memory-cleanup-draft

Conversation

@LaurenIsACoder

@LaurenIsACoder LaurenIsACoder commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Scope

Rebased replacement of the draft on bfe17ae7c1. This PR now contains only guest-thread resource ownership fixes:

  • Release thread-local IR2/immediate-cache allocations and non-owning TU/SMC indexes on normal exit and seccomp KILL_THREAD.
  • Roll back the child CPU, private GDT, fast jump cache and filter reference on failed thread creation; preserve the parent's allocations and return the pthread error correctly.
  • Reference-count immutable seccomp chains across clone, private installation, TSYNC, exit and fork. Publish an initialized child task and its inherited filter under the CPU-list lock; skip unpublished/exiting CPUs during TSYNC.
  • Publish new filter roots with release ordering and acquire them in syscall readers: the exclusive guest-execution barrier does not stop a thread already handling a syscall. This post-push self-review correction is folded into the original ownership commit, with a publication-contract RED/GREEN regression.
  • Release the netlink staging buffer on receive failure, drain and thread exit, restoring the caller's iovec before returning an error.

The obsolete AOT-reader changes from the draft are intentionally absent: upstream 17b479de7877 already fixed that reader, with regression coverage in 9bdce3bbe1cb. Those upstream fixes remain intact. Separate AOT merge/mapping fixes are not part of this PR.

Author self-review and combined validation

The actual published diffs were reviewed individually and checked against the local candidates. Follow-up corrections were folded into their existing commits; author/sign-off metadata updates preserved the per-PR source trees. The series remains six commits across #472, #473, #474, #475 and #476.

All five branches merge without conflicts on bfe17ae7c1. The combined source tree 80aaaaf13688387640f528d1c0bccb6a800f8d6e builds and passes 33/33 lat-pr-fast tests. On that combined binary, the 500-cycle KZT unload and retained-handle checks, 520-cycle SMC/fork checks, and 512 successful TSYNC operations alongside thread creation also complete successfully. A tests-disabled configuration registers no tests.

The integration suite still reports 27 skips, including after selecting the available guest sysroot with LATX_X86_64_SYSROOT: 25 require clang and two require the x86 cross compiler. These are not passes. This author self-review does not substitute for the upstream CI matrix, maintainer review or real-application acceptance.

Validation

LoongArch64, GCC 15.3, x86_64-linux-user, LAT O1, KZT compiled in, release (-DNDEBUG):

./configure --target-list=x86_64-linux-user --enable-latx --optimize-O1 \
  --extra-ldflags=-ldl --enable-kzt --enable-tests --disable-docs \
  --disable-werror --meson=meson
ninja -C build -j2 all meson-test-prereq
env -u LAT_LD_PREFIX meson test -C build --no-rebuild \
  --suite lat-pr-fast --print-errorlogs --num-processes 2
env -u LAT_LD_PREFIX meson test -C build --no-rebuild \
  --suite latx-integration --print-errorlogs --num-processes 2
  • This isolated PR branch: 26/26 lat-pr-fast passed.
  • Maintained production-body seams exercise normal/repeated/partial teardown, TU on/off, pending netlink and EAGAIN rollback, failed clone/cache initialization, TSYNC publication order, shared/private filter ownership and fork; debug and NDEBUG variants run without assertion-dependent setup.
  • The original upstream implementation fails the focused resource-ownership assertions. Earlier isolated x86 thread-churn and failed-clone reproductions established the corresponding growth and cleanup paths; these are not full application acceptance.
  • ASan/UBSan production-body ownership checks pass. The final source tree completes a 2,000-thread x86 churn run with bounded private-dirty memory after warm-up, 256 injected failed clones followed by a successful retry, and 512 successful TSYNC operations alongside 513 thread creations. Author/sign-off-only rewriting preserved that exact validated source tree.
  • Integration suite: 27 skipped (exit 77) because the required guest-building clang/toolchain environment is unavailable. Skips are not passes.

No cache capacity changes, installed translator replacement or running-application restart. Full application memory/compatibility acceptance and unavailable integration configurations remain separate gates.

@LaurenIsACoder
LaurenIsACoder force-pushed the latx-memory-cleanup-draft branch from 5152d3e to 5f5f8d2 Compare September 8, 2026 03:20
@LaurenIsACoder LaurenIsACoder changed the title LATX, fix: Reclaim thread translation state and AOT failure resources LATX, fix: Reclaim guest thread and seccomp ownership resources Sep 8, 2026
@LaurenIsACoder
LaurenIsACoder marked this pull request as ready for review September 8, 2026 03:20
@LaurenIsACoder
LaurenIsACoder force-pushed the latx-memory-cleanup-draft branch from 5f5f8d2 to 862c68a Compare September 8, 2026 03:41
Guest thread exit and failed clone paths leave translator allocations,
netlink staging buffers and seccomp filter references without an owner.
TSYNC can also observe a child before its task and filter are initialized.

Release thread-local translator resources on normal exit and KILL_THREAD,
and roll back child-owned resources when thread creation fails. Restore
netlink iovecs on receive failure and release pending buffers at teardown.
Reference-count immutable filter chains across clone, installation, TSYNC,
exit and fork. Publish initialized tasks under the CPU-list lock and use
release/acquire ordering for filter roots seen by syscall readers.

Add thread-cleanup and seccomp-lifetime regressions for partial teardown,
failed clone, filter ownership and publication order. The isolated branch
passed 26 lat-pr-fast tests, plus sanitizer ownership checks and focused
thread-churn, failed-clone and concurrent TSYNC workloads. Guest integration
tests requiring the unavailable toolchain were skipped.

Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant