Input: DualSense device paths end in a NUL #40

Open
github-bot wants to merge 1 commit from github-bot/gh-40 into main AGit
Owner

@⁠WHOISJARDAS on GitHub · 2026-11-25 12:34 UTC · original
WHOISJARDAS:input/dualsense-path-nul → main · +16 −2 · 1 files · 1 commits · open

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

**@⁠WHOISJARDAS** on GitHub · 2026-11-25 12:34 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/40) `WHOISJARDAS:input/dualsense-path-nul` → `main` · +16 −2 · 1 files · 1 commits · open `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)
`device_paths` copied each HID interface path without its NUL, and
`open_pad` passed the copy to `CreateFileW`, which reads a path up to its
NUL: past the end of the copy. With no DualSense connected the scan runs
every 2 s for the whole run, and once a copy ended a heap page the read
went into an unmapped page and the run ended (RX 9070 XT, no DualSense,
231 s into a run: 0xc0000005 at ntdll!wcslen <- RtlInitUnicodeStringEx
<- KERNELBASE!CreateFileInternal <- CreateFileW <- dualsense::reader).

Each path now keeps its NUL. New test: `device_paths_end_in_a_nul` (18
HID interfaces on that machine; it fails without the change).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:34:18 +00:00
Author
Owner

@⁠RodrigoTorreao on GitHub · 2026-11-25 17:58 UTC · original

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.

**@⁠RodrigoTorreao** on GitHub · 2026-11-25 17:58 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/40#issuecomment-7170250296) 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.
Author
Owner

@⁠Ekabusto on GitHub · 2026-11-25 13:39 UTC · original · reviewed

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.

**@⁠Ekabusto** on GitHub · 2026-11-25 13:39 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/40#pullrequestreview-6058637726) · **reviewed** 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/40/head:github-bot/gh-40'
git switch 'github-bot/gh-40'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-40'
git switch 'github-bot/gh-40'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-40'
git switch 'github-bot/gh-40'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-40'
git switch 'main'
git merge --squash 'github-bot/gh-40'
git switch 'main'
git merge --ff-only 'github-bot/gh-40'
git switch 'main'
git merge 'github-bot/gh-40'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.