Windows: relinker entry stub prints an orphan " -> FAILED" line without dependency diagnostics; fix branch ready #3307

Closed
opened 2026-10-11 06:49:34 +00:00 by Jnbla6 · 2 comments
Jnbla6 commented 2026-10-11 06:49:34 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Jnbla6 on 2026-10-11T06:49:34Z.


When LoadLibraryExW fails in the Windows entry stub and --dependency-diagnostics is not enabled, the entry stub starts its error output with a bare -> FAILED line before printing Failed to load module: …:

 -> FAILED
Failed to load module: …\libs\missing.prx
GetLastError: 126 - The specified module could not be found.

In WindowsEntryStubBuilder::Build, the "Loading PRX: " prefix (loading) before LoadLibraryExW and the " -> OK\n" suffix (loaded) after a successful load are both guarded by if (dependencyDiagnostics). However, writeString(loadFailed, true) (" -> FAILED\n") on the failure path is emitted unconditionally. Without --dependency-diagnostics, no "Loading PRX: …" prefix is written first, leaving -> FAILED as an orphan line at the start of stderr (and as the first line of anyps5.log in --windows-gui runs, as noted in #3282).

Proposal

  • Guard writeString(loadFailed, true) behind if (dependencyDiagnostics) in WindowsEntryStubBuilder::Build so it matches writeString(loading) and writeString(loaded).
  • With --dependency-diagnostics enabled, the output remains Loading PRX: <path> -> FAILED followed by Failed to load module: <path>.
  • Without --dependency-diagnostics, the output starts directly with Failed to load module: <path>.

Branch

Jnbla6/AnyPS5 fix/windows-stub-orphan-failed-line (3f85c8e4ec695dfe458e78a4b303c5981fcedd35):

  • PR #3312 ready
  • WindowsEntryStubBuilder.cpp: only emit loadFailed when dependencyDiagnostics is enabled.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5798737434 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3307). Originally posted by [Jnbla6](https://github.com/Jnbla6) on 2026-10-11T06:49:34Z. --- When `LoadLibraryExW` fails in the Windows entry stub and `--dependency-diagnostics` is not enabled, the entry stub starts its error output with a bare ` -> FAILED` line before printing `Failed to load module: …`: ```text -> FAILED Failed to load module: …\libs\missing.prx GetLastError: 126 - The specified module could not be found. ``` In `WindowsEntryStubBuilder::Build`, the `"Loading PRX: "` prefix (`loading`) before `LoadLibraryExW` and the `" -> OK\n"` suffix (`loaded`) after a successful load are both guarded by `if (dependencyDiagnostics)`. However, `writeString(loadFailed, true)` (`" -> FAILED\n"`) on the failure path is emitted unconditionally. Without `--dependency-diagnostics`, no `"Loading PRX: …"` prefix is written first, leaving ` -> FAILED` as an orphan line at the start of `stderr` (and as the first line of `anyps5.log` in `--windows-gui` runs, as noted in #3282). ### Proposal - Guard `writeString(loadFailed, true)` behind `if (dependencyDiagnostics)` in `WindowsEntryStubBuilder::Build` so it matches `writeString(loading)` and `writeString(loaded)`. - With `--dependency-diagnostics` enabled, the output remains `Loading PRX: <path> -> FAILED` followed by `Failed to load module: <path>`. - Without `--dependency-diagnostics`, the output starts directly with `Failed to load module: <path>`. ### Branch `Jnbla6/AnyPS5` `fix/windows-stub-orphan-failed-line` (`3f85c8e4ec695dfe458e78a4b303c5981fcedd35`): - `PR #3312 ready` - `WindowsEntryStubBuilder.cpp`: only emit `loadFailed` when `dependencyDiagnostics` is enabled.
reyani-dev commented 2026-10-11 07:43:12 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T07:43:12Z.


Carried as #3325 with your commit and authorship (only the message reworded to the conventional-commit form), plus a regression check in test_windows_import_modules.py. On native Windows the check fails against main (AssertionError: -> FAILED) and passes with your fix; the relinker suite passes 104/104.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106790591 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3307#issuecomment-6106790591). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-11T07:43:12Z. --- Carried as #3325 with your commit and authorship (only the message reworded to the conventional-commit form), plus a regression check in `test_windows_import_modules.py`. On native Windows the check fails against `main` (`AssertionError: -> FAILED`) and passes with your fix; the relinker suite passes 104/104.
Jnbla6 commented 2026-10-11 07:54:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Jnbla6 on 2026-10-11T07:54:09Z.


Thanks for carrying this over and adding the regression test

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106873408 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3307#issuecomment-6106873408). Originally posted by [Jnbla6](https://github.com/Jnbla6) on 2026-10-11T07:54:09Z. --- Thanks for carrying this over and adding the regression test
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#3307
No description provided.