Loader: evict module from MAPPED on DllMain false and TLS error (#106) #1376
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1376
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1376"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@slopgobblercobbler on GitHub · 2026-11-24 15:23 UTC · original
slopgobblercobbler:fix/loader-error-cleanup→main· +106 −5 · 2 files · 1 commits · openSummary
Fixes #106 Item 3:
DllMain(PROCESS_ATTACH)returnsFALSEduringload_game_dllor directinit_dll, unregisters the module fromMAPPEDviamodules::unregister_mapped(m.base). Previously, failing DLLs remained cached inMAPPED, causing subsequentload_game_dllcalls to returnOk(m)for an uninitialized or broken module.load_game_dll, if an existing mapped module is returned from cache, verifym.initialized.load(Ordering::Acquire). If initialization has not completed (e.g. concurrent race or pending attach), runinit_dll(&m)and evict on attach failure instead of assuming success.map_image_ex, handlepe.tls()parsing and static TLS installation errors cleanly instead of silently ignoring errors. Validate TLS index pointer and callback array offsets within the module bounds, and callmodules::unregister_mapped(base)on TLS failure to prevent leaving partially initialized modules registered.modules::unregister_mapped, clearMAINatomic pointer ifm.base == base.Changes
crates/xcl/src/loader.rs:init_dll: callmodules::unregister_mapped(m.base)onDllMainfailure (ret == 0).load_game_dll: checkm.initializedon cached module hits and run attach if needed; unregister on failure.map_image_ex: properly handle TLS directory parsing and carrier installation errors with module eviction.DllMain(PROCESS_ATTACH) == 0, corrupted TLS directory registration rollback, and uninitialized mapped module eviction.crates/xcl/src/modules.rs:unregister_mapped: clearMAINwhen unregistering the main module base.Tested
cargo test -p xcl -- loader: all 5 tests passed (100% pass):loader::tests::a_dll_whose_dllmain_fails_is_not_loadedloader::tests::a_dll_whose_direct_init_dll_fails_is_evicted_from_mappedloader::tests::a_dll_with_a_broken_import_table_is_not_left_registeredloader::tests::a_dll_with_a_broken_tls_directory_is_not_left_registeredloader::tests::uninitialized_mapped_module_evicted_if_init_fails_on_subsequent_loadNot Tested
AI Use
Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity
@futurepro62 on GitHub · 2026-11-24 15:32 UTC · original · edited 2026-11-24 15:38 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
ed6f612(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 754 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.a_dll_whose_direct_init_dll_fails_is_evicted_from_mapped,a_dll_with_a_broken_tls_directory_is_not_left_registered,uninitialized_mapped_module_evicted_if_init_fails_on_subsequent_load.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 754 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-24 16:41 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
@Toons29 on GitHub · 2026-11-25 03:27 UTC · original
Regression run of
ed6f6122on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 101 % of
main's frames, 99 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.