hle: return S_OK with null handle when PowerSetRequest returns ERROR_NOT_SUPPORTED #1663

Closed
Satanyuga wants to merge 1 commit from upstream-pr/1664 into main
Satanyuga commented 2026-11-24 20:34:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Satanyuga on 2026-11-24T20:34:29Z.


Fixes issue #727: program crashed on Windows ERROR_NOT_SUPPORTED (0x32) from PowerSetRequest in acquire_deferral.

Changes:

  • Extracted pure helper map_power_set_request_error(hr, out):
    • When hr == NOT_SUPPORTED (0x8007_0032), writes null to out via put() and returns S_OK.
    • Other errors returned unchanged; out untouched (COM rules).
  • handle_power_set_request_failure closes the request handle and delegates to the helper, passing the out pointer — eliminates UB from uninitialized out on S_OK return.
  • acquire_deferral calls the new helper on PowerSetRequest failure.

Tests added (all passing):

  • error_not_supported_returns_ok_with_null_handle — calls map_power_set_request_error(NOT_SUPPORTED, &mut out) and asserts hr == S_OK + out.is_null(), plus verifies E_FAIL leaves out untouched (sentinel preserved).
  • close_deferral_safely_ignores_null_handle — verifies close_deferral no-ops on null handle.

Verified:

  • cargo test -p victory-hle — 96 tests pass
  • cargo clippy -p victory-hle --all-targets -- -D warnings — 0 warnings, 0 errors
<!-- greyfinch-sync:Marvisak/VIctory:issue:6590878884 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1664). Originally posted by [Satanyuga](https://github.com/Satanyuga) on 2026-11-24T20:34:29Z. --- Fixes issue #727: program crashed on Windows `ERROR_NOT_SUPPORTED` (0x32) from `PowerSetRequest` in `acquire_deferral`. **Changes:** - Extracted pure helper `map_power_set_request_error(hr, out)`: - When `hr == NOT_SUPPORTED` (0x8007_0032), writes `null` to `out` via `put()` and returns `S_OK`. - Other errors returned unchanged; `out` untouched (COM rules). - `handle_power_set_request_failure` closes the request handle and delegates to the helper, passing the `out` pointer — eliminates UB from uninitialized `out` on `S_OK` return. - `acquire_deferral` calls the new helper on `PowerSetRequest` failure. **Tests added (all passing):** - `error_not_supported_returns_ok_with_null_handle` — calls `map_power_set_request_error(NOT_SUPPORTED, &mut out)` and asserts `hr == S_OK` + `out.is_null()`, plus verifies `E_FAIL` leaves `out` untouched (sentinel preserved). - `close_deferral_safely_ignores_null_handle` — verifies `close_deferral` no-ops on null handle. **Verified:** - `cargo test -p victory-hle` — 96 tests pass - `cargo clippy -p victory-hle --all-targets -- -D warnings` — 0 warnings, 0 errors
catminou4 commented 2026-11-24 22:01:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:41:51Z.

Review: COMMENTED


Static review only: Windows-only code (D3D12/windows_sys/Win32/HLE) — nothing compiles or runs on macOS; source review of the diff.

PowerSetRequest failure handling: ERROR_NOT_SUPPORTED (0x8007_0032) now returns S_OK with a null handle so headless/Wine/VM titles proceed and close_deferral no-ops; other errors keep the HRESULT and leave 'out' untouched per COM rules. The handle is closed before mapping. The pure helper map_power_set_request_error makes the branch testable. Windows-only.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047870868 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1664#pullrequestreview-6047870868). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:41:51Z. **Review:** COMMENTED --- Static review only: Windows-only code (D3D12/windows_sys/Win32/HLE) — nothing compiles or runs on macOS; source review of the diff. PowerSetRequest failure handling: ERROR_NOT_SUPPORTED (0x8007_0032) now returns S_OK with a null handle so headless/Wine/VM titles proceed and close_deferral no-ops; other errors keep the HRESULT and leave 'out' untouched per COM rules. The handle is closed before mapping. The pure helper map_power_set_request_error makes the branch testable. Windows-only.
acetonahard-code commented 2026-11-24 23:05:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T22:10:38Z.


Heads-up: #1155 (opened about four hours earlier) also says it fixes #727, the PowerSetRequest ERROR_NOT_SUPPORTED failure in acquire_deferral. The two conflict in display.rs, so only one can land as-is.

Tested on Windows 11 with the repo toolchain, merged into current main (70564ae):

cargo test -p victory-hle passed failed ignored
main 99 0 0
main + this PR 101 0 0
  • The 2 new tests pass.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145902659 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1664#issuecomment-7145902659). Originally posted by [acetonahard-code](https://github.com/acetonahard-code) on 2026-11-24T22:10:38Z. --- Heads-up: #1155 (opened about four hours earlier) also says it fixes #727, the `PowerSetRequest` `ERROR_NOT_SUPPORTED` failure in `acquire_deferral`. The two conflict in `display.rs`, so only one can land as-is. Tested on Windows 11 with the repo toolchain, merged into current `main` (70564ae): | `cargo test -p victory-hle` | passed | failed | ignored | |---|---|---|---| | `main` | 99 | 0 | 0 | | `main` + this PR | 101 | 0 | 0 | - The 2 new tests pass. - `cargo clippy --all-targets -- -D warnings`, with and without `--all-features`: clean. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
upstream-sync closed this pull request 2026-11-25 02:04:50 +00:00
Marvisak commented 2026-11-25 02:05:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:23:54Z.


Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #1155. Same fix for #727 as #1155, but it hands the title S_OK with a null handle; #1155's non-null no-op handle is the safer form of the same idea.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149502930 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1664#issuecomment-7149502930). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:23:54Z. --- Automated triage for the maintainers. Closing because another open pull request covers the same change. See #1155. Same fix for #727 as #1155, but it hands the title S_OK with a null handle; #1155's non-null no-op handle is the safer form of the same idea. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

Sign in to join this conversation.
No reviewers
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
Marvisak/VIctory!1663
No description provided.