D3D12-HLE-XNETWORKING-WIDE-ALIGNMENT: read title UTF-16 pointers unaligned in xnetworking::wide #2673
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2673"
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?
Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-30T01:42:51Z.
Claimed in #2570 as
D3D12-HLE-XNETWORKING-WIDE-ALIGNMENT(#issuecomment-7260961050).What and why
In
d3d12/crates/leonida-hle/src/modules/xnetworking.rs,wide(p: *const u16)dereferences the title's UTF-16 string pointer via*p.add(len)andstd::slice::from_raw_parts(p, len). Both require 2-byte alignment and trigger undefined behavior (aborting with0xc0000409/ misaligned pointer dereference in debug builds) when a title passes an odd-alignedu16pointer.This change reads UTF-16 code units with
p.add(len).read_unaligned()into aVec<u16>before callingString::from_utf16_lossy, matching the unaligned-read convention used elsewhere inleonida-hleandleonida-gpu.Verification (Red -> Green)
Hardware / OS: native Windows 11 Pro (
10.0.26200), AMD Ryzen 7 7800X3D, Rust1.98.cargo test -p leonida-hle --lib xnetworkingaborted with0xc0000409(misaligned pointer dereference inwide_reads_unaligned_utf16_stringson an odd-aligned buffer).main40e7fe69d):cargo test -p leonida-hle --lib xnetworking—2 passed; 0 failed.python -I scripts/check_no_game_data.py d3d12/crates/leonida-hle/src/modules/xnetworking.rs— PASS.AI-assisted: Antigravity (Gemini 4 Neon)
Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-11-30T11:25:22Z.
Independent Windows verification of
c23a0f51bonmaind367675c7(clean merge,6896ee602). Native Windows 11, MSVC x64, Rust 1.98.1, debugcargo test -p leonida-hle --lib.main+ only this PR's test hunk.modules::xnetworking::tests::wide_reads_unaligned_utf16_stringsaborts withmisaligned pointer dereference: address must be a multiple of 0x2atxnetworking.rs:85(the*text.add(i)inwide), exit0xc0000409.main+ this PR. That test passes; whole crate 219 passed, 2 ignored, 0 failed (main: 218 + this one).Read the change too: the loop stops at the first NUL exactly like the old
take_while, and null still givesNone, so aligned callers see the same string.GPUs tested: n/a (CPU unit tests). AI-assisted: yes.
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-11-30T16:05:45Z.
Independent check on Windows (not the author), at
c23a0f51b.cargo test --locked -p leonida-hle --lib: 219 passed, 0 failed, 2 ignored in 0.75 s.leonida-hleonly; no game run, so this covers the unaligned wide-pointer unit cases plus the crate's existing tests.Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, Rust 1.98.1 pinned.
AI-assisted: yes (opencode).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T16:19:50Z.
Merged on head
c23a0f51b. @Kal0s-design ran the red/green on this head (Windows 11, Rust 1.98.1: the new test aborts onmainand passes with this pull request); @KelboLive ran the crate green on this head (219 passed). CPU unit tests, no GPU. CI was green on this head and no test was run by the merger.Merged by MoonEyes. AI-assisted: yes (Claude Code).