Repository navigation
fix(libkernel): fail dlopen of an unrelinked module without the Windows Bad Image dialog - #9831
Closed
johandavidcm wants to merge 1 commit into
Closed
johandavidcm wants to merge 1 commit into
johandavidcm wants to merge 1 commit into
Conversation
…ws Bad Image dialog On Windows, dlopen passed a module that was never relinked to LoadLibraryExW, which raised the modal Bad Image hard-error dialog and blocked the calling thread until someone answered it. The load now runs with SEM_FAILCRITICALERRORS set for that thread only, so it fails at once with the same result as before. Every failed load is reported once per file on stderr with a [module] prefix; a file that exists with no relinked .guest.prx names the relinker's --module-dir option.
|
Thank you for your contribution! Authors with no pull requests merged into |
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.
What
On Windows,
dlopenpasses a module that was never relinked (a PS5 ELF or SELF that a title loads withsceKernelLoadStartModule) toLoadLibraryExW. Windows then raises its modal Bad Image hard-error dialog (0xC000012F), and the calling thread blocks until someone answers it. After that, the load fails with error 193 andsceKernelLoadStartModulereturnsSCE_KERNEL_ERROR_ENOENT, with nothing in the log.Yakuza 0 Director's Cut (PPSA31327) hits this whenever these modules are not relinked:
/app0/data/crm/ps5/crm_module_ps5.prx(the SEGA account module);/app0/data/module/ps5/yakuza_minigame_ps5_retail.prx.Unattended runs stall on the dialog.
LoadWithoutErrorDialogsetsSEM_FAILCRITICALERRORSon the calling thread for theLoadLibraryExWcall only, keeps the loader's error code, and restores the previous thread mode.PatchedLibraries.cppuses the same flag for its whole process. The module's initialization (InitializeDeferredModule) runs after the mode is restored.ENOENTand continues, as it did after someone answered the dialog.[module]prefix. This applies on Windows and on the other hosts.<name>.guest.prxgets:dlopen: <path> was not relinked: no <name>.guest.prx was found (Windows loader error 193); relink its directory with the relinker's --module-dir <dir> option.dlopen: cannot load <path> (<reason>).USAGE.mdmentions the message beside its existing note on error 193.Overlaps:
dlopen(fallback paths). Whichever PR merges second swaps itsLoadLibraryExWcalls forLoadWithoutErrorDialogand routes its final failure throughLoadFailure.__APPLE__blocks between the POSIX lines changed here, and feat(aot): consolidate native ARM64 compiler, runtime and consumers #5021 touches the CMake lines near the newTIMEOUT. These are line-level conflicts only.Tested
Windows 11 Pro 26200, WinLibs GCC 15.2.0, Release,
BUILD_TESTING=ON, onmain751b288.guest_dynamic_loadergains a check. dlopen of an existing 4-byte ELF stub that has no.guest.prxis called twice:SEM_NOGPFAULTERRORBOX.Each call must return null, with a dlerror that names the file and
--module-dir, and the thread mode must be unchanged afterwards. The missing-module dlerror must not mention--module-dir.main'sDynamicLoader.cpp, the test shows the Bad Image dialog and fails on the test's newTIMEOUT(30 s, the CI limit).was not relinkedline once for the two calls, and passes--repeat until-fail:20.Other tests that pass:
guest_dynamic_loader_variant_names,guest_deferred_module_{reload,pinned,parallel,reentrant},guest_module_info,guest_module_{dir,directories,args,identity,fini}andpatched_libraries.PPSA31327 01.015.000, relinked with only
--module-dir data/module/ps5, launched with the default error mode, from boot to gameplay. These runs used the change onmainb7d1d47; the rebase onto 751b288 touched none of the changed files.main's libraries, the Bad Image dialog forcrm_module_ps5.prxappears 6 s after start.[module] dlopen: ...crm_module_ps5.prx was not relinked ...line, and the title reaches gameplay.Linux:
DynamicLoader.cppandGuestDynamicLoader.cppcompile with GCC 15.2.0 (-Wall -Wextra, no warnings) in WSL Ubuntu. The test was not run there. On Linux and macOS the change is only the reporting:LoadFailureinstead ofError(::dlerror()).Not tested: macOS.
tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)