Skip to content

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

Merged
LaurenIsACoder merged 1 commit into
lat-opensource:masterfrom
LaurenIsACoder:latx-aot-memory-ownership
Sep 13, 2026
Merged

LaurenIsACoder merged 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 525b456fb5fc. 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, or replacement, instead of 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 or capacity. Thread ownership changes in #472 remain separate.

Validation

Validated on LoongArch64 with GCC 14.2.0. Both configurations used LAT O1, AOT, release settings, enabled tests, and at most two build or test processes.

../configure --target-list=x86_64-linux-user --enable-latx \
  --enable-latx-aot --optimize-O1 --extra-ldflags=-ldl --enable-kzt \
  --enable-tests --disable-debug-info --disable-docs --disable-werror \
  --meson=meson
ninja -j2 all meson-test-prereq
env -u LAT_LD_PREFIX meson test --suite lat-pr-fast --no-rebuild \
  --num-processes 2 --print-errorlogs

../configure --target-list=i386-linux-user --enable-latx \
  --enable-latx-aot --enable-guest-base-zero --optimize-O1 \
  --enable-tests --disable-debug-info --disable-docs --disable-werror \
  --meson=meson
ninja -j2 all meson-test-prereq
meson test --suite lat-pr-fast --no-rebuild --num-processes 2 \
  --print-errorlogs
  • x86_64-linux-user lat-pr-fast: 31/31 passed.
  • i386-linux-user lat-pr-fast: 21/21 passed.
  • The TU and non-TU merge regressions read controlled cache files through the production merger and assert balanced allocations across success, replacement, duplicate input, and error paths. Generated AOT code publication remains stubbed.
  • The segment-unmap regression invokes production target_munmap() with real host mappings. One range removes three segment/cache owners while preserving both neighbors; mincore() verifies the owned mappings were released. Invalid and repeated unmap are covered.
  • A tests-disabled configuration registers none of the PR's test targets.
  • git range-diff and stable patch IDs show the rebased commit is equivalent to the previously reviewed commit; author metadata, message, and Signed-off-by are preserved.

The current integration suite reports 34 skipped (exit 77): two lack the configured x86_64 guest sysroot, 26 lack Clang, and six lack x86_64-linux-gnu-gcc. These are not passes. No Wine application acceptance was run, and this PR does not claim 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>
@LaurenIsACoder
LaurenIsACoder force-pushed the latx-aot-memory-ownership branch from 325f9bf to 8047786 Compare September 13, 2026 06:36
@LaurenIsACoder
LaurenIsACoder merged commit 97429a3 into lat-opensource:master Sep 13, 2026
26 checks passed
@LaurenIsACoder
LaurenIsACoder deleted the latx-aot-memory-ownership branch September 13, 2026 07:02
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