A HID device path is handed to CreateFileW with its NUL (the emulator now and then died in wcslen) #207
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!207
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-207"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@SPFCChris on GitHub · 2026-11-25 22:50 UTC · original
SPFCChris:fix/dualsense-path-nul→main· +18 −2 · 1 files · 1 commits · openProblem
The emulator now and then ends with an access violation in
ntdll, on any machine without a DualSense connected:(The names are from the DLLs' exports and the build's
.pdb; Windows 11 build 26300.)dualsense::readerlooks at every HID interface every two seconds while no pad is open.device_pathscopies each device path out of the SetupAPI buffer without its terminating NUL:and
open_padgivesCreateFileWthe pointer,path.as_ptr(). So the path is read on into whatever follows the copy on the heap. Mostly a zero comes soon, and the call fails or opens the device all the same. When none comes before the end of the mapped memory,wcslenfaults and the process is gone. In the cases logged here the scan ran some 28 KB past the start of the string.Three of about sixty runs of four to six minutes ended this way on this machine (Ryzen AI Max+ 395, no pad), in different builds and settings, which is how it came to notice: I first took them for the title's own crashes.
It came in with
34a0823("Input: read DualSense pads over HID when XInput has none").Change
The copy keeps the NUL (
len + 1). One line, plus the print in the ignored listing test, which now leaves the NUL out of what it prints.Test
modules::dualsense::tests::device_paths_keep_their_terminator: every path the machine has ends in a NUL and holds no other. It passes with no HID interface at all.Tested
cargo test -p victory-hle --lib --locked dualsense: 7 passed, 0 failed, 1 ignored.Not tested
AI-assisted (Claude Code); no game data.
🤖 Generated with Claude Code
@adrianmjim on GitHub · 2026-11-26 19:50 UTC · original
Tested natively on Windows 11 build 26300 with an RX 7900 XT (driver 32.0.32029.2010) and Rust 1.98.1. PR head is
25643c8and the base is4f62c2a. No DualSense is connected. The machine has 33 HID interfaces.cargo test -p victory-hle --lib --locked dualsenseon the PR: 7 passed, 1 ignored.4f62c2a):device_paths_keep_their_terminatorfails. The last element of a path is125(}), not0. So the test catches the bug on any machine with at least one HID interface.device_paths()returns it is copied to the end of a page whose next page isPAGE_NOACCESS. It is then passed toCreateFileWwith the same arguments asopen_pad.4f62c2a: the test process ends with0xc0000005(STATUS_ACCESS_VIOLATION) in 3 of 3 runs.victory-hlelib run, 3 times each on base and PR: no new failures. The only failures are the 5 knownxmemtests (#2, #8, #107), the same on both.Not tested: a real DualSense, and the emulator itself.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.