LATX, fix: Reclaim public-loader metadata and repeated search paths - #475
Open
LaurenIsACoder wants to merge 2 commits into
Open
LATX, fix: Reclaim public-loader metadata and repeated search paths#475LaurenIsACoder wants to merge 2 commits into
LaurenIsACoder wants to merge 2 commits into
Conversation
Repeated prepends of the same normalized library-search path allocate new entries indefinitely. Simply ignoring duplicates would change lookup precedence when an existing path must become the first search location. Reuse the normalized entry and move it to the front when prepending it again. Preserve the relative order of the remaining paths. Add path-collection regression coverage for normalized duplicates and prepend order. This test passed in the loader-lifetime branch's 26-test lat-pr-fast suite. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Repeated public-loader dlopen/dlclose cycles leave stale ELF metadata in the context even after its guest mappings disappear. Freeing it immediately would invalidate metadata still borrowed by native frames or RCU readers. At a guest-execution safe point, scan under the mapping lock using a fresh loader snapshot and retire unowned metadata through RCU. Retain the main executable, attached libraries, malloc-backed borrowers, live link-map entries and ELFs with surviving load segments. Reuse vacant context slots without shifting other library indexes. Busy or stale snapshots and an exclusive-barrier timeout conservatively defer reclamation. Add lifecycle regressions for retained owners, snapshots, slot reuse and deferred destruction. The branch passed 26 lat-pr-fast tests and sanitizer checks. A 500-cycle libbz2 loader workload kept elfsize at 7; retaining a handle kept it at 8. This does not bound translation caches or establish full application memory stability; unavailable integration tests were skipped. Requires the queued-RCU fork fix in PR lat-opensource#474 before merging, so a child preserves inherited metadata retirements. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
This was referenced Sep 8, 2026
LaurenIsACoder
force-pushed
the
latx-kzt-loader-lifetime
branch
from
September 8, 2026 07:07
c8b15db to
3789458
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope and merge dependency
Based on upstream
bfe17ae7c1. Merge #474 first: this PR queues unloaded-header retirement through RCU, so inherited queued retirements need the fork-accounting fix. The branch remains independently based on master to keep the review focused.Two commits preserve the ownership boundaries:
Keep the main executable, attached libraries, malloc-backed borrowers, live link-map entries and any ELF with a still-valid load segment. Clear/reuse vacant context slots without shifting other library indexes. This frees metadata, not guest mappings. A busy loader or exclusive-barrier timeout conservatively retains metadata until a later loader event; this is not unconditional immediate reclamation.
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 tree80aaaaf13688387640f528d1c0bccb6a800f8d6ebuilds 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:
LATX_AOT=0,LATX_KZT=2,LATX_KZT_LIBS=core. GDB samples showmy_context->elfsizeremains 7, versus growth from 7 to 507 on the earlier unfixed baseline. With a retained handle and checked function calls it stays 8, and the guest exits successfully. A KZT-disabled control also exits successfully.No installed runtime changes or running-application restart.