Input: DualSense device paths end in a NUL #40

Open
WHOISJARDAS wants to merge 1 commit from upstream-pr/40 into main
WHOISJARDAS commented 2026-11-25 12:34:55 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by WHOISJARDAS on 2026-11-25T12:34:55Z.


device_paths copies each HID interface path without its terminating NUL (from_raw_parts(path, len).to_vec()), and open_pad passes the copy to CreateFileW, which reads a path up to its NUL, so it read past the end of the copy. With no DualSense connected the scan runs every 2 s for the whole run, and once a copy happened to end a heap page, the read went into an unmapped page and the run ended.

Seen here on this fork's 4cbe9d7 (+ the low 4 GiB guards, so that it starts on this machine): RX 9070 XT, no DualSense connected, 231 s into the run:

VIctory: unhandled exception 0xc0000005 at ntdll.dll+0x125a74 (read 0x174a4d0000: no access)
  ntdll!wcslen+0x74
  ntdll!RtlInitUnicodeStringEx+0x21
  KERNELBASE!CreateFileInternal+0xf3
  KERNELBASE!CreateFileW+0x97
  victory_hle::modules::dualsense::reader+0x3fd  (open_pad, inlined)

(names from Microsoft's public symbols for this machine's ntdll/KernelBase and the diag build's PDB)

Each path now keeps its NUL (path.push(0)). New test device_paths_end_in_a_nul checks every path the scan returns: on this machine 18 HID interfaces; it fails without the change and passes with it. The ignored lists_and_opens_hid_devices prints the paths without the NUL.

The same code is in Marvisak/VIctory#150, where this module comes from; I'll leave a note there.

Tested

  • cargo test -p victory-hle --lib dualsense: 7 passed, 1 ignored (the new test fails without the change)
  • cargo clippy -p victory-hle --all-targets: no new findings (the ones it reports are in victory-shader, the same on 4cbe9d7)
  • Not tested: a connected DualSense (none here); the change only adds the NUL to the paths it opens.

AI use: Claude Code (Claude Opus 5.5) found it from the crash stack and wrote the change and the test; the run and the hardware are mine.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:6604593218 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/40). Originally posted by [WHOISJARDAS](https://github.com/WHOISJARDAS) on 2026-11-25T12:34:55Z. --- `device_paths` copies each HID interface path without its terminating NUL (`from_raw_parts(path, len).to_vec()`), and `open_pad` passes the copy to `CreateFileW`, which reads a path up to its NUL, so it read past the end of the copy. With no DualSense connected the scan runs every 2 s for the whole run, and once a copy happened to end a heap page, the read went into an unmapped page and the run ended. Seen here on this fork's `4cbe9d7` (+ the low 4 GiB guards, so that it starts on this machine): RX 9070 XT, no DualSense connected, 231 s into the run: ``` VIctory: unhandled exception 0xc0000005 at ntdll.dll+0x125a74 (read 0x174a4d0000: no access) ntdll!wcslen+0x74 ntdll!RtlInitUnicodeStringEx+0x21 KERNELBASE!CreateFileInternal+0xf3 KERNELBASE!CreateFileW+0x97 victory_hle::modules::dualsense::reader+0x3fd (open_pad, inlined) ``` (names from Microsoft's public symbols for this machine's ntdll/KernelBase and the diag build's PDB) Each path now keeps its NUL (`path.push(0)`). New test `device_paths_end_in_a_nul` checks every path the scan returns: on this machine 18 HID interfaces; it fails without the change and passes with it. The ignored `lists_and_opens_hid_devices` prints the paths without the NUL. The same code is in Marvisak/VIctory#150, where this module comes from; I'll leave a note there. ## Tested - `cargo test -p victory-hle --lib dualsense`: 7 passed, 1 ignored (the new test fails without the change) - `cargo clippy -p victory-hle --all-targets`: no new findings (the ones it reports are in `victory-shader`, the same on `4cbe9d7`) - Not tested: a connected DualSense (none here); the change only adds the NUL to the paths it opens. AI use: Claude Code (Claude Opus 5.5) found it from the crash stack and wrote the change and the test; the run and the hardware are mine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Ekabusto commented 2026-11-25 13:39:04 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by Ekabusto on 2026-11-25T13:39:04Z.

Review: COMMENTED


Tested here: RX 9070 XT (Adrenalin 26.11.2, driver 32.0.32029.2010), Ryzen 9 5900X, 32 GB, Windows 11 build 26300, no DualSense connected.

Without the fix (main at 71652a2): the run crashed 11 min 22 s in with the same signature as in the description:

VIctory: unhandled exception 0xc0000005 at ntdll.dll+0x12d844 (read 0x218c11d5000: no access)
  #0  ntdll.dll+0x12d844
  #1  ntdll.dll+0xb5251
  #2  KERNELBASE.dll+0x1e377
  #3  KERNELBASE.dll+0x1fc67
  #4  victory.exe+0xd1efd   victory_hle::modules::dualsense::reader+0x3fc  (dualsense.rs:105)

(victory.exe frame resolved against the release build's PDB.)

With the fix: the change applied cleanly on top of main at 71652a2. I tested that, not the PR branch, which is 9 commits behind.

  • cargo test -p victory-hle --lib dualsense: 7 passed, 1 ignored, including device_paths_end_in_a_nul.
  • Game run: more than 14 minutes in the world with no crash so far. That's past the point where the unpatched run died. Since the crash depends on where a heap copy happens to land, this makes the fix more likely to work but doesn't prove it.

Not tested: a connected DualSense.

The change looks right to me: CreateFileW needs a NUL-terminated path, and the new test covers it.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:review:6058637726 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/40#pullrequestreview-6058637726). Originally posted by [Ekabusto](https://github.com/Ekabusto) on 2026-11-25T13:39:04Z. **Review:** COMMENTED --- Tested here: RX 9070 XT (Adrenalin 26.11.2, driver 32.0.32029.2010), Ryzen 9 5900X, 32 GB, Windows 11 build 26300, no DualSense connected. **Without the fix (`main` at 71652a2):** the run crashed 11 min 22 s in with the same signature as in the description: ``` VIctory: unhandled exception 0xc0000005 at ntdll.dll+0x12d844 (read 0x218c11d5000: no access) #0 ntdll.dll+0x12d844 #1 ntdll.dll+0xb5251 #2 KERNELBASE.dll+0x1e377 #3 KERNELBASE.dll+0x1fc67 #4 victory.exe+0xd1efd victory_hle::modules::dualsense::reader+0x3fc (dualsense.rs:105) ``` (victory.exe frame resolved against the release build's PDB.) **With the fix:** the change applied cleanly on top of `main` at 71652a2. I tested that, not the PR branch, which is 9 commits behind. - `cargo test -p victory-hle --lib dualsense`: 7 passed, 1 ignored, including `device_paths_end_in_a_nul`. - Game run: more than 14 minutes in the world with no crash so far. That's past the point where the unpatched run died. Since the crash depends on where a heap copy happens to land, this makes the fix more likely to work but doesn't prove it. Not tested: a connected DualSense. The change looks right to me: `CreateFileW` needs a NUL-terminated path, and the new test covers it.
RodrigoTorreao commented 2026-11-25 17:58:01 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by RodrigoTorreao on 2026-11-25T17:58:01Z.


Seen on a second machine, before this PR: RX 6750 XT, i5-14600KF, 16 GB RAM, Windows 11 26200, no DualSense connected, diag build of 01aadd1 (plus a local change in victory-gpu unrelated to input). The run ended 697 s in, while the world was being drawn:

VIctory: unhandled exception 0xc0000005 at ntdll.dll+0x12d844 (read 0x21b012a3000: no access)
  #0  ntdll.dll+0x12d844
  #1  ntdll.dll+0xb5251
  #2  KERNELBASE.dll+0x1e377
  #3  KERNELBASE.dll+0x1fc67
  #4  victory.exe+0xe107d   victory_hle::modules::dualsense::reader+0x3fd (dualsense.rs:105)

The same reader+0x3fd as in your trace, and a read address at the start of a page. I named frame #4 from the diag build's PDB with dbghelp; I did not look up the ntdll/KernelBase names. It happened again on main a59f3e5 (same local change), 20 s into the run, at the same ntdll.dll+0x12d844, read 0x2449395e000: 2 of the 9 runs I made today without this PR.

With this PR's commit (9501e2a) cherry-picked, 3 runs (129 to 399 s) had no such crash. Since the crash depends on where a heap page ends, that shows little on its own; the change reads right to me: CreateFileW gets a NUL-terminated path now.

AI-assisted (Claude Code): the runs, the symbol lookup and this text. No game data.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7170250296 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/40#issuecomment-7170250296). Originally posted by [RodrigoTorreao](https://github.com/RodrigoTorreao) on 2026-11-25T17:58:01Z. --- Seen on a second machine, before this PR: RX 6750 XT, i5-14600KF, 16 GB RAM, Windows 11 26200, no DualSense connected, diag build of `01aadd1` (plus a local change in `victory-gpu` unrelated to input). The run ended 697 s in, while the world was being drawn: ``` VIctory: unhandled exception 0xc0000005 at ntdll.dll+0x12d844 (read 0x21b012a3000: no access) #0 ntdll.dll+0x12d844 #1 ntdll.dll+0xb5251 #2 KERNELBASE.dll+0x1e377 #3 KERNELBASE.dll+0x1fc67 #4 victory.exe+0xe107d victory_hle::modules::dualsense::reader+0x3fd (dualsense.rs:105) ``` The same `reader+0x3fd` as in your trace, and a read address at the start of a page. I named frame #4 from the diag build's PDB with dbghelp; I did not look up the ntdll/KernelBase names. It happened again on `main` `a59f3e5` (same local change), 20 s into the run, at the same `ntdll.dll+0x12d844`, read `0x2449395e000`: 2 of the 9 runs I made today without this PR. With this PR's commit (`9501e2a`) cherry-picked, 3 runs (129 to 399 s) had no such crash. Since the crash depends on where a heap page ends, that shows little on its own; the change reads right to me: `CreateFileW` gets a NUL-terminated path now. AI-assisted (Claude Code): the runs, the symbol lookup and this text. No game data.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/40:upstream-pr/40'
git switch 'upstream-pr/40'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/40'
git switch 'upstream-pr/40'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/40'
git switch 'upstream-pr/40'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/40'
git switch 'main'
git merge --squash 'upstream-pr/40'
git switch 'main'
git merge --ff-only 'upstream-pr/40'
git switch 'main'
git merge 'upstream-pr/40'
git push origin 'main'
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
Belobug/VIctory-Belobug-AMD!40
No description provided.