test(avplayer): guest_avplayer fails intermittently in full builds (Linux and Windows) #2709

Closed
opened 2026-10-10 11:51:04 +00:00 by adriadam10 · 9 comments
adriadam10 commented 2026-10-10 11:51:04 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T11:51:04Z.


guest_avplayer fails intermittently in the full build, on both Linux and Windows, on a commit that doesn't touch libSceAvPlayer.

Seen while building #2661 (workflow_dispatch -f pr=2661), whose change is limited to libSceAgcDriver and the shader recompiler:

  • run 38045519945, Windows: passed in attempt 1 (3.31 s) and failed in attempt 2 at core/libs/tests/GuestAvPlayer.cpp:724, enable video failed.
  • run 38048934826, Linux: Subprocess aborted after 1.55 s. The test's std::abort() calls are in the allocator and event callbacks (lines 507 and 552).

guest_avplayer_tests links only libSceAvPlayer and libc. Locally (Linux, RADV and lavapipe) it passed 6 runs out of 6 on the same tree, so it looks timing-dependent. Recent libSceAvPlayer changes on main include 068da6a99 (skip late video frames in no-sync mode while audio drives the clock).

AI-assisted: yes (Claude).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5790949595 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2709). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T11:51:04Z. --- `guest_avplayer` fails intermittently in the full build, on both Linux and Windows, on a commit that doesn't touch libSceAvPlayer. Seen while building #2661 (`workflow_dispatch -f pr=2661`), whose change is limited to libSceAgcDriver and the shader recompiler: - run 38045519945, Windows: passed in attempt 1 (3.31 s) and failed in attempt 2 at `core/libs/tests/GuestAvPlayer.cpp:724`, `enable video failed`. - run 38048934826, Linux: `Subprocess aborted` after 1.55 s. The test's `std::abort()` calls are in the allocator and event callbacks (lines 507 and 552). `guest_avplayer_tests` links only `libSceAvPlayer` and `libc`. Locally (Linux, RADV and lavapipe) it passed 6 runs out of 6 on the same tree, so it looks timing-dependent. Recent libSceAvPlayer changes on main include 068da6a99 (skip late video frames in no-sync mode while audio drives the clock). AI-assisted: yes (Claude).
MarcZX10 commented 2026-10-10 12:08:02 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-10T12:08:02Z.


I traced the enable video failed path on current main. FfmpegSource::EnableStream returns false only when the index is out of range or started is already true. This test verifies that there are three streams and that index VideoStream is the video stream, then calls EnableStream; its first explicit sceAvPlayerStart is later, after both stream enables. Because the test supplies an event callback, Player should also have auto-start disabled. This is source-level narrowing, not a reproduction: the Windows report therefore points to the source already being marked started before the explicit start, or to the failing binary/input differing from the reported setup.

Could you capture the actual return value from sceAvPlayerEnableStream and, if possible, a debugger stack for the Linux abort? The two std::abort sites in the test are independent checks:

Abort site What it would establish
Release (around line 507) A pointer was released twice, was not allocated by the test allocator, or was released through the wrong memory/texture callback.
OnEvent (around line 552) The callback received a nonzero event source or an event ID/data-pointer combination outside the test's expected contract.

A Linux backtrace (gdb --batch -ex run -ex bt --args ./guest_avplayer_tests) and the full Windows failure log would separate these paths from the EnableStream result. The locally reported 6/6 passes do not yet establish the cause of either CI failure.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6097324398 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2709#issuecomment-6097324398). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-10T12:08:02Z. --- I traced the `enable video failed` path on current `main`. `FfmpegSource::EnableStream` returns `false` only when the index is out of range or `started` is already true. This test verifies that there are three streams and that index `VideoStream` is the video stream, then calls `EnableStream`; its first explicit `sceAvPlayerStart` is later, after both stream enables. Because the test supplies an event callback, `Player` should also have auto-start disabled. This is source-level narrowing, not a reproduction: the Windows report therefore points to the source already being marked started before the explicit start, or to the failing binary/input differing from the reported setup. Could you capture the actual return value from `sceAvPlayerEnableStream` and, if possible, a debugger stack for the Linux abort? The two `std::abort` sites in the test are independent checks: | Abort site | What it would establish | |---|---| | `Release` (around line 507) | A pointer was released twice, was not allocated by the test allocator, or was released through the wrong memory/texture callback. | | `OnEvent` (around line 552) | The callback received a nonzero event source or an event ID/data-pointer combination outside the test's expected contract. | A Linux backtrace (`gdb --batch -ex run -ex bt --args ./guest_avplayer_tests`) and the full Windows failure log would separate these paths from the `EnableStream` result. The locally reported 6/6 passes do not yet establish the cause of either CI failure.
Yuva1024 commented 2026-10-10 13:56:53 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Yuva1024 on 2026-10-10T13:56:53Z.


Reproduced the enable video failed failure on Windows and fixed it. Fix: b7dec57a on branch fix/avplayer-unsynced-test-autostart of https://github.com/Yuva1024/AnyPS5 (one file, +2/-1, on main 8b812318). The PR (#2770) was closed automatically by the intake rule; its Conventions check passed.

Cause. TestUnsyncedVideoKeepsUpWithAudio is the only test that calls sceAvPlayerEnableStream by hand on a player created with no event callback (InitData(nullptr)). Player turns auto-start on in that case (autoStartEnabled = init.auto_start || callback.event_callback == nullptr, Player.cpp:65), so its controller thread runs autoStart(), which enables the streams and calls Start(), shortly after AddSource. If that lands before the test's EnableStream, Source::EnableStream returns false because started is true (Source.cpp:280). The test thread usually wins; with the CPU busy the controller sometimes does.

Measured (Windows 11 26200, WinLibs GCC 15.2.0 r7, Release, Ryzen 5 5600G, main ba2a0a31):

  • guest_avplayer_tests: 0 of 40 runs fail serially; 1 of 180 fails with six copies running in parallel (enable video failed, exit 1).
  • With a 60 ms pause before the test's EnableStream: 10 of 10 runs fail with enable video failed.
  • With the fix (the test gets an Events object, so auto-start is off): the same pause gives 10 of 10 passes; at normal timing 460 of 460 pass (100 serial, six loops of 60 in parallel).
  • check_conventions.py passes, and the full ctest is 709/709.

The other four tests without a callback do not call EnableStream, so they have no such race. This does not account for the Linux abort at the allocator and event callback in the description; I could not test Linux, so that may be the same race showing a different symptom, or a separate cause.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6098231871 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2709#issuecomment-6098231871). Originally posted by [Yuva1024](https://github.com/Yuva1024) on 2026-10-10T13:56:53Z. --- Reproduced the `enable video failed` failure on Windows and fixed it. Fix: [`b7dec57a`](https://github.com/Yuva1024/AnyPS5/commit/b7dec57a84771328770f3054a28d8d83ce2ae6fe) on branch [`fix/avplayer-unsynced-test-autostart`](https://github.com/Yuva1024/AnyPS5/tree/fix/avplayer-unsynced-test-autostart) of https://github.com/Yuva1024/AnyPS5 (one file, +2/-1, on `main` 8b812318). The PR (#2770) was closed automatically by the intake rule; its Conventions check passed. **Cause.** `TestUnsyncedVideoKeepsUpWithAudio` is the only test that calls `sceAvPlayerEnableStream` by hand on a player created with no event callback (`InitData(nullptr)`). `Player` turns auto-start on in that case (`autoStartEnabled = init.auto_start || callback.event_callback == nullptr`, `Player.cpp:65`), so its controller thread runs `autoStart()`, which enables the streams and calls `Start()`, shortly after `AddSource`. If that lands before the test's `EnableStream`, `Source::EnableStream` returns false because `started` is true (`Source.cpp:280`). The test thread usually wins; with the CPU busy the controller sometimes does. **Measured** (Windows 11 26200, WinLibs GCC 15.2.0 r7, Release, Ryzen 5 5600G, `main` ba2a0a31): - `guest_avplayer_tests`: 0 of 40 runs fail serially; 1 of 180 fails with six copies running in parallel (`enable video failed`, exit 1). - With a 60 ms pause before the test's `EnableStream`: 10 of 10 runs fail with `enable video failed`. - With the fix (the test gets an `Events` object, so auto-start is off): the same pause gives 10 of 10 passes; at normal timing 460 of 460 pass (100 serial, six loops of 60 in parallel). - `check_conventions.py` passes, and the full `ctest` is 709/709. The other four tests without a callback do not call `EnableStream`, so they have no such race. This does not account for the Linux abort at the allocator and event callback in the description; I could not test Linux, so that may be the same race showing a different symptom, or a separate cause. AI-assisted: yes (Claude Code).
Yassin6up commented 2026-10-10 15:01:44 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Yassin6up on 2026-10-10T15:01:44Z.


Reproduced and explained the Linux abort.

Reproduction (Linux, Ubuntu 24.04, GCC 13.3, main 8b812318): 8 copies of guest_avplayer_tests in parallel plus 2 busy loops, 22 of 200 runs abort (SIGABRT). gdb shows the abort in _Unwind_RaiseException_Phase2, called from _Unwind_Resume in a landing pad of TestUnsyncedVideoKeepsUpWithAudio. Printing the Check message before the throw shows that all of them are "enable video failed", the same auto-start race as on Windows.

Why it aborts instead of printing the message: guest_avplayer_tests imports __cxa_throw and __cxa_begin_catch, and the first library that defines them is libc.prx (loaded before libstdc++), so a failed Check throws through libc.prx's unwinder. But -static-libgcc links a private, hidden copy of _Unwind_Resume into the test, and the landing pad of the test function resumes with it. Phase 2 of that copy cannot continue the unwind that libc.prx's copy started. A forced Check(false) at the start of TestPlayback aborts in the same way every time, while a throw directly in main (no landing pad) is caught and printed. Relinking the test with -shared-libgcc makes _Unwind_Resume resolve to libc.prx too, and the forced failure prints its message and exits with 1.

Fix for the abort: commit fa5199cd8 on branch claude/peaceful-fermat-us6v6j of https://github.com/Yassin6up/AnyPS5 (applies to main 8b812318). guest_avplayer_tests is linked without -static-libgcc/-static-libstdc++/-static, as the AgcDriver, Agc and VideoOut test executables already are. Results on Linux:

  • forced Check failure: abort before, message and exit code 1 after
  • unmodified test: passes
  • same stress run: no aborts; 30 of 200 print "enable video failed" and 1 prints "video frame is not a texture allocation" (CheckVideoFrame), a second intermittent failure the aborts were hiding
  • check_conventions.py passes; Windows not tested

The race itself: Yuva1024's b7dec57a (event callback in TestUnsyncedVideoKeepsUpWithAudio) also fixes it on Linux: 0 of 240 failures in the same stress run with the static runtime, where unmodified main fails 22 of 200.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6098842621 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2709#issuecomment-6098842621). Originally posted by [Yassin6up](https://github.com/Yassin6up) on 2026-10-10T15:01:44Z. --- Reproduced and explained the Linux abort. Reproduction (Linux, Ubuntu 24.04, GCC 13.3, main 8b812318): 8 copies of guest_avplayer_tests in parallel plus 2 busy loops, 22 of 200 runs abort (SIGABRT). gdb shows the abort in _Unwind_RaiseException_Phase2, called from _Unwind_Resume in a landing pad of TestUnsyncedVideoKeepsUpWithAudio. Printing the Check message before the throw shows that all of them are "enable video failed", the same auto-start race as on Windows. Why it aborts instead of printing the message: guest_avplayer_tests imports __cxa_throw and __cxa_begin_catch, and the first library that defines them is libc.prx (loaded before libstdc++), so a failed Check throws through libc.prx's unwinder. But -static-libgcc links a private, hidden copy of _Unwind_Resume into the test, and the landing pad of the test function resumes with it. Phase 2 of that copy cannot continue the unwind that libc.prx's copy started. A forced Check(false) at the start of TestPlayback aborts in the same way every time, while a throw directly in main (no landing pad) is caught and printed. Relinking the test with -shared-libgcc makes _Unwind_Resume resolve to libc.prx too, and the forced failure prints its message and exits with 1. Fix for the abort: commit fa5199cd8 on branch claude/peaceful-fermat-us6v6j of https://github.com/Yassin6up/AnyPS5 (applies to main 8b812318). guest_avplayer_tests is linked without -static-libgcc/-static-libstdc++/-static, as the AgcDriver, Agc and VideoOut test executables already are. Results on Linux: - forced Check failure: abort before, message and exit code 1 after - unmodified test: passes - same stress run: no aborts; 30 of 200 print "enable video failed" and 1 prints "video frame is not a texture allocation" (CheckVideoFrame), a second intermittent failure the aborts were hiding - check_conventions.py passes; Windows not tested The race itself: Yuva1024's b7dec57a (event callback in TestUnsyncedVideoKeepsUpWithAudio) also fixes it on Linux: 0 of 240 failures in the same stress run with the static runtime, where unmodified main fails 22 of 200. AI-assisted: yes.
adriadam10 commented 2026-10-10 22:59:47 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T22:59:47Z.


Fixed in part by #2770: the enable video failed race (auto-start vs the test's manual EnableStream); the abort on a failing Check is still open.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103099152 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2709#issuecomment-6103099152). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T22:59:47Z. --- Fixed in part by #2770: the `enable video failed` race (auto-start vs the test's manual `EnableStream`); the abort on a failing `Check` is still open.
oneandonlydean commented 2026-10-13 07:38:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T07:38:13Z.


#4256 is on main. Has guest_avplayer failed in a full build since? If not, this can close.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140713097 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2709#issuecomment-6140713097). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T07:38:13Z. --- #4256 is on main. Has `guest_avplayer` failed in a full build since? If not, this can close.
arreina commented 2026-10-14 06:06:21 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by arreina on 2026-10-14T06:06:21Z.


Data point for closing this: I could not reproduce the intermittent failure on current main.

Stress run (Linux Mint 22.3, GCC 13.3, AddressSanitizer + UBSan build, tree at upstream 77b9f7270 with only unrelated fork changes): guest_avplayer_tests 1000 times, 8 copies in parallel plus 2 busy loops, the recipe @Yassin6up described above (22 of 200 aborted before the #2770 and #4256 fixes). Result: 0 failures in 1000 runs.

One thing to watch for if someone repeats this: the test writes app0/avplayer.mp4 relative to the current directory and truncates it, so parallel copies must each run in their own working directory. With a shared one I got 3 failures in 200 (add source failed), which come from copies overwriting each other's file and are not a player bug.

Full CI: guest_avplayer also passed in 8 of 8 recent full builds (4 runs, Linux and Windows) on the same tree.

So I believe this can be closed.

AI-assisted: yes (Claude).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162061852 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2709#issuecomment-6162061852). Originally posted by [arreina](https://github.com/arreina) on 2026-10-14T06:06:21Z. --- Data point for closing this: I could not reproduce the intermittent failure on current `main`. **Stress run** (Linux Mint 22.3, GCC 13.3, AddressSanitizer + UBSan build, tree at upstream `77b9f7270` with only unrelated fork changes): `guest_avplayer_tests` 1000 times, 8 copies in parallel plus 2 busy loops, the recipe @Yassin6up described above (22 of 200 aborted before the #2770 and #4256 fixes). Result: **0 failures in 1000 runs**. One thing to watch for if someone repeats this: the test writes `app0/avplayer.mp4` relative to the current directory and truncates it, so parallel copies must each run in their own working directory. With a shared one I got 3 failures in 200 (`add source failed`), which come from copies overwriting each other's file and are not a player bug. **Full CI**: `guest_avplayer` also passed in 8 of 8 recent full builds (4 runs, Linux and Windows) on the same tree. So I believe this can be closed. AI-assisted: yes (Claude).
oneandonlydean commented 2026-10-14 06:53:32 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T06:53:32Z.


Closing as fixed by #2770 and #4256: 1000 stress runs on current main had no failure. If guest_avplayer fails in a full build again, reopen with the run link.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162699043 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2709#issuecomment-6162699043). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T06:53:32Z. --- Closing as fixed by #2770 and #4256: 1000 stress runs on current main had no failure. If `guest_avplayer` fails in a full build again, reopen with the run link.
simonbronk commented 2026-10-14 08:12:29 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-14T08:12:29Z.


@oneandonlydean yes: guest_avplayer failed again on current main (1209d3707) with enable video failed, on Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, once in four full non-GPU ctest -j 16 runs (AI-assisted: Claude Code).

It is the same auto-start race as before, in a test added after #4256: TestRestartAfterPausedJumpKeepsClockRunning (from #4652, a671dc4ed) creates the player with InitData(nullptr), so Player enables auto-start, and then calls sceAvPlayerEnableStream by hand. When the controller's autoStart() runs first, EnableStream returns an error because the source is already started.

Giving it an event callback, as #2770 did for TestUnsyncedVideoKeepsUpWithAudio, removes the race:

 void TestRestartAfterPausedJumpKeepsClockRunning() {
-    AvPlayerInitData init = InitData(nullptr);
+    Events events;
+    AvPlayerInitData init = InitData(&events);

Checked the same way as #2770, with a 60 ms sleep inserted before that test's EnableStream (not part of the fix):

  • without the change: guest_avplayer fails 10/10 with enable video failed;
  • with the change: passes 10/10.

Without the sleep, with the change: guest_avplayer passes 30/30 (--repeat until-fail:30).

cc @xXPBSXx

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6163932201 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2709#issuecomment-6163932201). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-14T08:12:29Z. --- @oneandonlydean yes: `guest_avplayer` failed again on current `main` (`1209d3707`) with `enable video failed`, on Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, once in four full non-GPU `ctest -j 16` runs (AI-assisted: Claude Code). It is the same auto-start race as before, in a test added after #4256: `TestRestartAfterPausedJumpKeepsClockRunning` (from #4652, `a671dc4ed`) creates the player with `InitData(nullptr)`, so `Player` enables auto-start, and then calls `sceAvPlayerEnableStream` by hand. When the controller's `autoStart()` runs first, `EnableStream` returns an error because the source is already started. Giving it an event callback, as #2770 did for `TestUnsyncedVideoKeepsUpWithAudio`, removes the race: ```diff void TestRestartAfterPausedJumpKeepsClockRunning() { - AvPlayerInitData init = InitData(nullptr); + Events events; + AvPlayerInitData init = InitData(&events); ``` Checked the same way as #2770, with a 60 ms sleep inserted before that test's `EnableStream` (not part of the fix): - without the change: `guest_avplayer` fails 10/10 with `enable video failed`; - with the change: passes 10/10. Without the sleep, with the change: `guest_avplayer` passes 30/30 (`--repeat until-fail:30`). cc @xXPBSXx
oneandonlydean commented 2026-10-14 08:59:39 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T08:59:39Z.


Thanks @simonbronk, your fix is in as #5733: the paused-jump restart test now gets an event callback like the one #2770 added, and it passed 30 runs in a row here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6164729543 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2709#issuecomment-6164729543). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T08:59:39Z. --- Thanks @simonbronk, your fix is in as #5733: the paused-jump restart test now gets an event callback like the one #2770 added, and it passed 30 runs in a row here.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#2709
No description provided.