Repository navigation
Conversation
When GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS was not set, module_handle_ex delegated to module_handle_impl (GetModuleHandleW), ignoring flags. Real Windows DLLs returned without incrementing or pinning their reference count, so a matching FreeLibrary prematurely unloaded the DLL. Invalid flag combinations (such as PIN | UNCHANGED_REFCOUNT or unknown bits) were also accepted. Validate GetModuleHandleEx flags (rejecting unknown bits and PIN | UNCHANGED_REFCOUNT with ERROR_INVALID_PARAMETER) and forward real Windows DLL lookups to ll::GetModuleHandleExW(flags, ...). Assisted-by: OpenCode (Gemini 4 Neon)
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Note: the full |
|
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
Thanks! — Devin |
…dev#1235, kernelx twin) Windows hle/kernelx.rs hunks verbatim reference-only (cfg(windows)-only): win_module_handle helper, module_handle_impl -> module_handle_in_ex, module_handle_in cfg(test) shim, PIN/UNCHANGED_REFCOUNT consts, unknown-bit + PIN|UNCHANGED combo guard, FROM_ADDRESS/null/name legs via the helper, plus the refcount/flags test. Linux twin hle/kernelx_linux.rs gets flag-validation only (win64 ABI untouched, upstream guard order): unknown bits or PIN|UNCHANGED_REFCOUNT -> *out=0 + ERROR_INVALID_PARAMETER. The refcount-bump half has no Linux hook point (resolver_linux::system_module is a stub returning None), so only validation ports. New Linux-shaped twin test covers the invalid combo + unknown bit (FAILED pre-fix, green post-fix) plus a valid-name control. Triage-close xcl-dev#864 as already landed with citation, no code: export at hle/kernelx.rs:61, impl at :876 returns 0, test at :3077, resolver pin at resolver.rs:503. Gates: both cargo checks 0 errors; lib 686/0/1 (+1); diff --check clean; title fresh-root 12 GPU-only; retail SIGSEGV +0x2237320 HOLDS.
|
Nothing has happened on this PR for 3 days, so it is marked |
|
Not on main: AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
merge-check
|
When
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESSwas not set,module_handle_exdelegated tomodule_handle_impl(GetModuleHandleW), ignoringflags. Real Windows DLLs were returned without incrementing or pinning their reference count, so a matchingFreeLibraryprematurely unloaded the DLL. Invalid flag combinations (such asPIN | UNCHANGED_REFCOUNTor unknown bits) were also accepted.This validates
GetModuleHandleExflags (rejecting unknown bits andPIN | UNCHANGED_REFCOUNTwithERROR_INVALID_PARAMETER) and forwards real Windows DLL lookups toll::GetModuleHandleExW(flags, ...).What is in it
crates/xcl/src/hle/kernelx.rs: addwin_module_handleandmodule_handle_in_ex, validate flags inmodule_handle_ex, and forward real Windows DLL name lookups toll::GetModuleHandleExW; add unit testget_module_handle_ex_honours_refcount_and_rejects_invalid_flags(verified failing before the fix).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib get_module_handle_ex_honours_refcount_and_rejects_invalid_flags: 1 passed, 0 failed (failed before the fix)Regression run
main:
PR:
Not tested
AI use
kernelx.rs, wrote the fix and regression test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.