test(agc): keep the Vulkan drivers loaded across the pipeline journal test #11721

Merged
jotitadev merged 2 commits from upstream-pr/11721 into main 2026-10-29 12:48:51 +00:00
jotitadev commented 2026-10-27 05:28:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T05:28:56Z.


What

agc_driver_pipeline_journal fails on main on a Linux host that has the NVIDIA ICD and a second ICD (here lavapipe), with the oversized record was not counted as a write failure. With only one ICD it passes.

The test opens and closes about fifteen VulkanDevices in one process. Each one creates and destroys its own instance, and the loader unloads every ICD when an instance is destroyed, then loads them again for the next one. glibc does not give back the static TLS that a library with initial-exec TLS takes, and NVIDIA's libnvidia-tls.so is such a library. With two ICDs the block runs out after about ten cycles; from then on the loader logs

[Vulkan Loader] ERROR:          /usr/lib/x86_64-linux-gnu/libnvidia-tls.so.595.99.02: cannot allocate memory in static TLS block
[Vulkan Loader] ERROR | DRIVER: loader_icd_scan: Failed loading library associated with ICD JSON libGLX_nvidia.so.0. Ignoring this JSON

and enumerates only lavapipe (Physical device count=1). The next device opens on lavapipe, the journal says belongs to another device; the journal is off for this run, and the oversized-record check fails. Device selection is not the cause: the driver's selection and ANYPS5_GPU see only what the loader enumerates, and with ANYPS5_GPU=NVIDIA the same run stops with Vulkan: no usable device whose name contains ANYPS5_GPU="NVIDIA"; devices: llvmpipe (LLVM 21.1.8, 256 bits). Production opens one device per process, so this only shows in a test that cycles devices.

The same thing reproduces outside AnyPS5 with a 25-line C loop (dlopen the loader, vkCreateInstance, enumerate, vkDestroyInstance, dlclose): NVIDIA drops out at cycle 10 with both ICDs, and at cycle 26 with only the NVIDIA ICD. Keeping one instance alive for the whole loop keeps both devices for all 30 cycles. Not unloading the loader is not enough; the ICDs go when the last instance goes. GLIBC_TUNABLES=glibc.rtld.optional_static_tls=2048 also makes the test pass, which confirms the cause.

The test now holds one instance for the life of the process on glibc, before it opens its first device, so the ICDs stay loaded and each device reuses them. Only this test changes.

Tested

Ubuntu 26.04, glibc 2.43, GCC 15.2, Release, ninja -j3. NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. ANYPS5_REQUIRE_VULKAN=1, ctest -R '^agc_driver_pipeline_journal$' -j1. Base main 4297464b1; the branch is that change rebased onto current main with no conflict and no change to the files involved.

ICDs present main this change
NVIDIA + lavapipe (default selection picks the 3070) fail 3/3, the oversized record was not counted as a write failure pass 5/5
NVIDIA only (VK_ICD_FILENAMES) pass 3/3 pass 5/5
lavapipe only (VK_ICD_FILENAMES) pass 1/1 pass 5/5
NVIDIA + lavapipe, ANYPS5_GPU=llvmpipe pass

With both ICDs, the binary run directly with VK_LOADER_DEBUG=error: on main 10 devices open on the 3070 and 2 on lavapipe, with 2 static-TLS errors; with this change all 15 open on the 3070, 0 errors, 0 belongs to another device. With ANYPS5_GPU=llvmpipe all 15 open on lavapipe.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5029079145 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11721). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-27T05:28:56Z. --- ### What `agc_driver_pipeline_journal` fails on `main` on a Linux host that has the NVIDIA ICD and a second ICD (here lavapipe), with `the oversized record was not counted as a write failure`. With only one ICD it passes. The test opens and closes about fifteen `VulkanDevice`s in one process. Each one creates and destroys its own instance, and the loader unloads every ICD when an instance is destroyed, then loads them again for the next one. glibc does not give back the static TLS that a library with initial-exec TLS takes, and NVIDIA's `libnvidia-tls.so` is such a library. With two ICDs the block runs out after about ten cycles; from then on the loader logs ``` [Vulkan Loader] ERROR: /usr/lib/x86_64-linux-gnu/libnvidia-tls.so.595.99.02: cannot allocate memory in static TLS block [Vulkan Loader] ERROR | DRIVER: loader_icd_scan: Failed loading library associated with ICD JSON libGLX_nvidia.so.0. Ignoring this JSON ``` and enumerates only lavapipe (`Physical device count=1`). The next device opens on lavapipe, the journal says `belongs to another device; the journal is off for this run`, and the oversized-record check fails. Device selection is not the cause: the driver's selection and `ANYPS5_GPU` see only what the loader enumerates, and with `ANYPS5_GPU=NVIDIA` the same run stops with `Vulkan: no usable device whose name contains ANYPS5_GPU="NVIDIA"; devices: llvmpipe (LLVM 21.1.8, 256 bits)`. Production opens one device per process, so this only shows in a test that cycles devices. The same thing reproduces outside AnyPS5 with a 25-line C loop (`dlopen` the loader, `vkCreateInstance`, enumerate, `vkDestroyInstance`, `dlclose`): NVIDIA drops out at cycle 10 with both ICDs, and at cycle 26 with only the NVIDIA ICD. Keeping one instance alive for the whole loop keeps both devices for all 30 cycles. Not unloading the loader is not enough; the ICDs go when the last instance goes. `GLIBC_TUNABLES=glibc.rtld.optional_static_tls=2048` also makes the test pass, which confirms the cause. The test now holds one instance for the life of the process on glibc, before it opens its first device, so the ICDs stay loaded and each device reuses them. Only this test changes. ### Tested Ubuntu 26.04, glibc 2.43, GCC 15.2, Release, `ninja -j3`. NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. `ANYPS5_REQUIRE_VULKAN=1`, `ctest -R '^agc_driver_pipeline_journal$' -j1`. Base `main` `4297464b1`; the branch is that change rebased onto current `main` with no conflict and no change to the files involved. | ICDs present | `main` | this change | |---|---|---| | NVIDIA + lavapipe (default selection picks the 3070) | **fail** 3/3, `the oversized record was not counted as a write failure` | pass 5/5 | | NVIDIA only (`VK_ICD_FILENAMES`) | pass 3/3 | pass 5/5 | | lavapipe only (`VK_ICD_FILENAMES`) | pass 1/1 | pass 5/5 | | NVIDIA + lavapipe, `ANYPS5_GPU=llvmpipe` | | pass | With both ICDs, the binary run directly with `VK_LOADER_DEBUG=error`: on `main` 10 devices open on the 3070 and 2 on lavapipe, with 2 static-TLS errors; with this change all 15 open on the 3070, 0 errors, 0 `belongs to another device`. With `ANYPS5_GPU=llvmpipe` all 15 open on lavapipe. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04 - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-27 05:34:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T05:34:22Z.

Review: CHANGES_REQUESTED


The test-only workaround matches the reported glibc/NVIDIA TLS exhaustion, and I syntax-checked the changed PipelineJournal.cpp with this target's configured GCC flags successfully. The author also provides a detailed same-machine main-vs-change run across both ICDs and each ICD separately.

One Linux build portability issue remains: this change adds direct dlopen/dlsym references, but agc_driver_pipeline_journal_tests does not link ${CMAKE_DL_LIBS}. The generated target link line has no -ldl; this works with glibc 2.34+ because libdl was integrated into libc, but not with glibc 2.33 and earlier where the symbols live in libdl. The project build requirements do not set a glibc 2.34 minimum. Please add ${CMAKE_DL_LIBS} to this test target and rerun its link/test. I could not run the Vulkan runtime test locally; the current hosted product-build jobs are skipped by path policy.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5662667084 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11721#pullrequestreview-5662667084). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T05:34:22Z. **Review:** CHANGES_REQUESTED --- The test-only workaround matches the reported glibc/NVIDIA TLS exhaustion, and I syntax-checked the changed `PipelineJournal.cpp` with this target's configured GCC flags successfully. The author also provides a detailed same-machine main-vs-change run across both ICDs and each ICD separately. One Linux build portability issue remains: this change adds direct `dlopen`/`dlsym` references, but `agc_driver_pipeline_journal_tests` does not link `${CMAKE_DL_LIBS}`. The generated target link line has no `-ldl`; this works with glibc 2.34+ because libdl was integrated into libc, but not with glibc 2.33 and earlier where the symbols live in libdl. The project build requirements do not set a glibc 2.34 minimum. Please add `${CMAKE_DL_LIBS}` to this test target and rerun its link/test. I could not run the Vulkan runtime test locally; the current hosted product-build jobs are skipped by path policy.
MarcZX10 commented 2026-10-27 06:42:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T06:42:15Z.

Review: APPROVED


The requested link dependency is now added to the test target, and the author reports the rebuilt link line includes plus successful focused runs with both ICDs, each ICD separately, and CTest. I inspected the exact two-file diff and the targeted policy checks pass. Hosted product build jobs remain skipped; I did not run this Vulkan test locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5663182829 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11721#pullrequestreview-5663182829). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T06:42:15Z. **Review:** APPROVED --- The requested link dependency is now added to the test target, and the author reports the rebuilt link line includes plus successful focused runs with both ICDs, each ICD separately, and CTest. I inspected the exact two-file diff and the targeted policy checks pass. Hosted product build jobs remain skipped; I did not run this Vulkan test locally.
Sign in to join this conversation.
No reviewers
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!11721
No description provided.