fix(tests): destroy the pad input before the pad identify test quits SDL #14438
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14438"
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 boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-11-01T13:22:17Z.
What
The nightly sanitizer run of 2026-11-01 (run 41270298089) failed
pad_identify_connect,pad_identify_offandpad_identify_rumblewith an AddressSanitizer heap-use-after-free inSDL_GameControllerClose(SDL_gamecontroller.c:3036). InRunofPadIdentify.cpp,padInputis a local that lives to the end of the function, butSDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK)runs before that and frees every controller that is still open;~PadInputthen callsSDL_GameControllerCloseon the freed controller. This putspadInputand the checks that use it in their own block, so it is destroyed before the virtual controller is detached and SDL is quit. Only the test changes: the shutdown of the title already does it in this order (VideoOutDriverresetspadInputon the present thread beforeSDL_QuitSubSystem).Tested
WSL Ubuntu 24.04 with gcc 13.3, Release,
ANYPS5_ENABLE_ASAN=ONand-g1. Onmaine67cc81869each of the three tests fails in 3 of 3 runs with a heap-use-after-free report atSDL_gamecontroller.c:3036, the same line as in the nightly; the test file is the same atba627802e2, the base of this branch; with this change each passes 3 of 3 runs with no AddressSanitizer output, andpad_identify_invalidpasses.tools/check_conventions.py --base upstream/mainpasses. Not run: Windows (AddressSanitizer is Linux only), the UndefinedBehaviorSanitizer flags the nightly adds, and the other tests of the repository.Overlap
I took the changed files of each of the 1661 open pull requests from
git diff --name-onlyagainst its merge base (listed at 11:56 UTC on 2026-11-01; one ref, #13454, could not be fetched, and its GitHub file list does not showPadIdentify.cpp). None of them changescore/libs/prx/libSceVideoOut/tests/PadIdentify.cpp.git merge-treeagainstmainf1a7b02028(checked at 13:19 UTC on 2026-11-01): this head merges cleanly. None of the 33 pull requests opened since (#14401 to #14435) changesPadIdentify.cpp.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T13:49:11Z.
Review: COMMENTED
Reviewed — no blocking findings
Scoping
padInputin its own block makes it destroy before the virtual controller is detached and beforeSDL_QuitSubSystem, which is the ordering the use-after-free report needs; the change is confined to one test file and reads correctly at head185adf1624.What I ran
185adf16249616e4e1e1176d6eb21dfb18c9e0ce, basef1a7b02028(the PR base)./usr/bin/python33.11.2, no build.python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14438 --output-dir /dev/shm/reviewer-run/precheck/14438gh apicontents at185adf16: the block closes at line 122,SDL_JoystickDetachVirtual(device)is at line 124, andSDL_QuitSubSystemat line 125.Results
Precheck report, checks table, unedited (
/dev/shm/reviewer-run/precheck/14438/report.md):The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check f1a7b02028ae50adaf6c5aaaef892a51841b25bf...185adf16249616e4e1e1176d6eb21dfb18c9e0ce/usr/bin/python3 tools/check_conventions.py --base f1a7b02028ae50adaf6c5aaaef892a51841b25bf --head 185adf16249616e4e1e1176d6eb21dfb18c9e0ce --title fix(tests): destroy the pad input before the pad identify test quits SDL --body /dev/shm/reviewer-run/precheck/14438/pr-body.md/usr/bin/python3 tools/pr_abi_audit.py --base f1a7b02028ae50adaf6c5aaaef892a51841b25bf --head 185adf16249616e4e1e1176d6eb21dfb18c9e0ce --jsonNo changed Python implementation files.No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.No changed test_*.py files./usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14438 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14438/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./usr/bin/python3 /dev/shm/reviewer-run/precheck/14438/head-185adf162496-c9cc4e01/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14438/head-185adf162496-c9cc4e01 --json core/libs/prx/libSceVideoOut/tests/PadIdentify.cppNo changed Python test module in tools/ can be run as a no-build base-source control.The ABI audit row is not applicable: the change touches no export or header.
Negative control
Not run here. The PR reports that each of the three tests fails with a heap-use-after-free on
main, under ASan, in 3 of 3 runs; that is the author's report.Findings
Blocking: none.
Non-blocking: none.
Sources
github.com/boykopovar/AnyPS5@185adf1624/core/libs/prx/libSceVideoOut/tests/PadIdentify.cpp (L99-L126)Not verified