Repository navigation
Conversation
The retail executable imports GameInput.dll by ordinal 1, and only the name GameInputCreate was registered, so the loader fell through to the host's gameinput.dll. That host answers GameInputCreate with a null interface; the title ignores the HRESULT, stores the null and calls AddRef/Release through it, which is a page fault at address 0. Register the "ProjectLeonida#1" alias, and add a no-SDL provider compiled only when the SDL3 shim is not: one static object, real QueryInterface/AddRef/Release, E_NOTIMPL (writing nothing) for every other slot. A ctest covers the ordinal, the object and the refusal.
al3xar
left a comment
There was a problem hiding this comment.
Tested 4d964643f on Windows 11 x64, MSVC 19.44.35230.0 (VS 2022 Build Tools), CMake + Ninja RelWithDebInfo, Windows SDK 10.0.26100.0 (no SDL3 installed): pass on build & tests, with one small review note below.
Verification
- Merges cleanly onto
upstream/main(dde82f27e). - Built
gta6rtandgameinput_no_sdl_testcleanly with zero warnings in the added/modified files. gameinput_no_sdl_test.exeandctest -R gameinput_no_sdl: 9/9 checks OK (exit 0).python -I tests/test_ctest_registration.py -v: 4/4 OK.python -I scripts/check_no_game_data.py runtime/CMakeLists.txt runtime/shims/gameinput.cpp runtime/shims/gameinput_no_sdl.cpp runtime/test/gameinput_no_sdl_test.cpp: clean (exit 0).- Local
gta6rt.exe --dry-runagainst the retail 1.0.2.1 executable (counts only):GameInput.dll!#1moves from host to shim (shim=61 host=432onmain->shim=62 host=431on4d964643f;unimplemented=22unchanged; exit 0).
Code review note
runtime/test/gameinput_no_sdl_test.cpp:35:check(release(object) >= 0, "slot 2 (Release) is callable and does not underflow")is tautologically true becauseULONGis unsigned (an underflow to0xFFFFFFFFstill satisfies>= 0). Meanwhilestub_releaseinruntime/shims/gameinput_no_sdl.cpp:67doesg_refs.fetch_sub(1) - 1unconditionally, so extraRelease()calls will wrapg_refstoUINT32_MAX. Checkingrelease(object) == before - 1(or clampingg_refsagainst underflow instub_release) would actually test the underflow claim.- Minor:
gameinput.cppalso registersxgameruntime.dll!GameInputCreate;gameinput_no_sdl.cppomits that alias (fine if intentional, just noting for parity).
AI-assisted.
|
Independent CPU-only review of 4d96464 (AI-assisted). Finding: QueryInterface advertises unsupported interfaces. In runtime/shims/gameinput_no_sdl.cpp, stub_qi() ignores riid, always returns S_OK, increments the reference count and provides the global GameInput object. An isolated C++ reproduction confirms that querying IID_NULL returns S_OK with a non-null interface pointer instead of E_NOINTERFACE with a null output. This differs from the existing SDL-backed gameinput.cpp, which accepts only IID_IUnknown and IID_IGameInput for the main interface. Suggested correction: Accept only supported interface IDs, return E_NOINTERFACE and set *out = nullptr for unsupported IDs, and add a regression test covering IID_NULL. The ordinal-import registration and no-SDL fallback are useful changes. This finding concerns COM interface correctness, not the import-resolution fix. Verification limitation: I compiled and executed an isolated transcription of the relevant logic using GCC on Linux. I did not independently build or execute Leonida's Windows runtime. |
|
checked: no-SDL3 path under Wine, retail 1.0.2.1 package | base: base-stack@57b88dec1 + #6964 + #6954 + #2490 + #7216 + #6943, plus this PR's diff applied (no SDL3 in the build, so |
tupacfan04
left a comment
There was a problem hiding this comment.
The #1 ordinal alias is correct, but the no-SDL fallback and its test have real defects.
-
Missing
xgameruntime.dll!GameInputCreate. The SDL shim registers three pairs (gameinput.cpp:2647-2650):gameinput.dllGameInputCreate,gameinput.dll#1, andxgameruntime.dllGameInputCreate. The no-SDL table (gameinput_no_sdl.cpp:81-86) omits the third, whiledocs/gameinput.md:475-476says both modules are served. Becausexgameruntime.dllis owned by the shim, a caller using that documented path gets null instead of the fallback; the no-SDL test checks onlygameinput.dll. Add the pair and assert it in the test. -
The Release test is vacuous.
gameinput_no_sdl_test.cpp:35checksrelease(object) >= 0on aULONG, which is always true. The fallback (gameinput_no_sdl.cpp:67) also lacks the SDL shim’srelease_floor, so an extra release wraps the refcount. Floor the fallback and assert exact counts / non-UINT_MAX. -
The device-query test uses the wrong slot/signature.
IGameInputv0 slot 9 isRegisterDeviceCallback(seven arguments; the callback token out-parameter is the seventh), not a three-argumentGetDevices. The current call passes&devicesasstatusFilterand never supplies the token pointer, so the “unserved slot writes nothing” claim is not tested. Use the full seven-argument signature with a sentinel token, orGetCurrentReadingat slot 4.
Additional: stub_qi ignores riid and returns S_OK for any IID, unlike the SDL QueryInterface (E_NOINTERFACE); the SDL path’s new #1 alias is not checked by gameinput_test.cpp:1474-1477; docs/gameinput.md, runtime/CMakeLists.txt:372-373, and the else() message at :427-433 still say a no-SDL build has no GameInputCreate.
Correct: the #-ordinal convention, both tables’ gameinput.dll/#1 entries, mutual exclusivity, and the no-SDL target registration. No game files; code read only. AI-assisted (OpenCode).
|
Independent build + test: builds and the new test passes, but this replaces the documented host GameInput path on Windows (BUG / design conflict) AI-assisted (Claude Code). Windows 11 x64, MSVC 19.44.35220, Ninja RelWithDebInfo. GPU (not used): NVIDIA GeForce RTX 3080 driver 621.24 / 32.0.16.2124. Head
Problem: the loader checks shims before host DLLs ( The crash the PR describes (a null interface from the host's DLL) is a Wine problem. One option is to serve the stub only when the host Other notes:
|
…tLeonida#7896) The retail executable imports GameInput.dll by ordinal 1 only, so the name-only shim entry was never bound and the loader fell through to the host's GameInput. Applied from upstream PR ProjectLeonida#7896 (diff applied; the PR branch conflicts in an unrelated file). Measured on build-boot configured with the local static SDL3 (-DSDL3_DIR): the boot logs the shim's SDL line, the thread dumps have no host gameinputredist threads, and 6,000+ PresentX in 110 s as before. The title's nine accessor callers use IGameInput slots 4, 5, 6, 9, 13 and 16, all v0 slots the shim serves. gameinput_test: 341 checks pass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…rojectLeonida#7896, remaining PRs (ProjectLeonida#9670 ProjectLeonida#9419 ProjectLeonida#9549 ProjectLeonida#9499 ProjectLeonida#9229 ProjectLeonida#9189 ProjectLeonida#7685 ProjectLeonida#9467) and lazy PSO Tree is the integrated boot-path state; history keeps the fork's earlier merges.
Claimed in the coordination issue as a new RT-5 item.
What was wrong
The retail executable imports
GameInput.dllby ordinal 1.runtime/shims/gameinput.cppregisters only the name:{"gameinput.dll", "GameInputCreate", reinterpret_cast<void*>(&GameInputCreate)},so the registry lookup for the key
"#1"misses, the loader falls through to the host'sgameinput.dll, and on wine that host answersGameInputCreatewith a null interface. The title ignores the HRESULT, stores the null in its lazy singleton and calls AddRef/Release through it:Second half of the same gap:
gameinput.cppis only compiled when SDL3 is available, so a CPU-only build serves nothing for that import and every consumer falls through to the host.What this changes
{"gameinput.dll", "#1", …}next to the name.runtime/shims/gameinput_no_sdl.cpp, compiled only when the SDL3 shim is not: one static object whose slots 0/1/2 are QueryInterface/AddRef/Release and every other slot returnsE_NOTIMPL, so a caller that only holds and releases the interface survives and one that asks for devices gets a clean refusal instead of a null dereference. It carries a one-time stderr note that it is serving without SDL and therefore has no devices.runtime/test/gameinput_no_sdl_test.cpp+ ctestgameinput_no_sdl: the ordinal resolves, the object is non-null, AddRef/Release are callable, an unserved slot returnsE_NOTIMPLand writes nothing to its out-parameter, and a null out-parameter isE_POINTER.Testing
--dry-runon the retail executable at this commit, before and after: the executable's import split moves fromshim=62 host=431tohost=430 shim=63— one import that used to resolve to the host's module now resolves to the shim, and the total unimplemented count is unchanged.On a real
--runwith the boot-path PRs applied, the guest stop atgame+0x5925903(read at address 0) is gone, the trace prints[rt] gameinput: served without SDL3 (no devices; E_NOTIMPL for every other slot), and the boot continues to the next stop. That measurement is what makes this a fix rather than a tidy-up; the Windows table never had this gap because the console executable's import table is what it is on both hosts, but only the ordinal key was ever registered.No game data: symbol names, counts and one guest mnemonic sequence. AI-assisted.