Skip to content

LATX, fix: Release AOT merge and invalidated segment resources - #473

Open
LaurenIsACoder wants to merge 1 commit into
lat-opensource:masterfrom
LaurenIsACoder:latx-aot-memory-ownership
Open

LATX, fix: Release AOT merge and invalidated segment resources#473
LaurenIsACoder wants to merge 1 commit into
lat-opensource:masterfrom
LaurenIsACoder:latx-aot-memory-ownership

Conversation

@LaurenIsACoder

@LaurenIsACoder LaurenIsACoder commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Scope

Based on current upstream bfe17ae7c1. Fix AOT resources whose owning operation has finished:

  • Free both merge-input buffers and their vector on success, duplicate input and errors.
  • Destroy non-TU merge indexes before their borrowed input data is freed; free owned TB-index values on replacement and destruction.
  • Free directory-scan allocations when opening the cache directory fails.
  • Invalidate every overlapping segment on successful unmap/remap/replacement, not only the first match. Segment-owned address-specific PE/cache mappings are released; reusable ELF library-cache entries retain their existing policy.

This does not duplicate upstream's AOT reader fix (17b479de7877) or change the cache format/capacity. Thread ownership changes in #472 are separate; this PR does not depend on them.

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 build:

./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
  • Isolated PR branch: 27/27 lat-pr-fast passed.
  • New TU/non-TU merge regressions read controlled real cache files through the production merger and assert balanced allocations, including replacement and failure paths. TU translation/publication endpoints are stubbed; this is ownership-path evidence, not execution of generated AOT code.
  • New unmap regression invokes production target_munmap with real host mappings: a single range removes three segment/cache owners while preserving both neighbors; mincore verifies the released mappings. Invalid and repeated unmap are covered.
  • Earlier RED runs on the unfixed upstream production bodies fail the ownership checks.
  • Integration suite: 27 skipped (exit 77) due to the unavailable clang/guest-building toolchain. These are not passes. Broader guest mapping/AOT compatibility remains an integration gate.

No installed runtime changes or claim of full application memory acceptance.

AOT merging retains input buffers and index allocations after completion
or failure. Mapping invalidation only releases the first overlapping
segment, leaving other segment-owned cache mappings alive.

Release merge inputs and their vector on all exit paths, destroy borrowed
indexes before their input buffers, and free owned TB-index values on
replacement and destruction. Clean up failed directory scans and invalidate
every overlapping segment after successful unmap, remap or replacement.
Keep the existing reusable ELF cache policy and cache format unchanged.

Add TU/non-TU merge ownership tests and a segment-unmap test using real host
mappings. The unfixed production paths fail the ownership checks; the fixed
isolated branch passed 27 lat-pr-fast tests. The merge tests stub generated
code publication, and unavailable guest integration tests 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