Skip to content

fix(libc): share guest environment with exported environ - #15095

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
lgqdaxia:codex/fix-guest-environment-coherence
Nov 15, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
lgqdaxia:codex/fix-guest-environment-coherence

Conversation

@lgqdaxia

@lgqdaxia lgqdaxia commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What

Follow-up to Discussion #11161: bind libc's environment APIs to libkernel's exported environ, so API calls and direct table replacements see the same values.

Loading libkernel adopts the existing environment; actual unload detaches to libc-owned storage and reload binds again. Whole/null/offset table replacements, live putenv aliases, owned-string retention and allocation-failure preservation are covered. The guest environment remains separate from host HOME/PATH.

Adoption and unload are separate tests. Adoption never skips; unload may report loader retention. The Linux skip audit accepts only that exact unload test and diagnostic, not other skips or Windows retention.

Tested

Nov 12, head bd2dd42740 on main e4aa14827b: rebased and moved the three new test executables into the required per-executable CMake fragments. Registration commands and all other topic changes are unchanged. All 41 skip-audit checks, fragment parsing/BUILD_TESTING=OFF inclusion, Python syntax, whitespace and exact PR conventions pass.

Scope: same-process coherence. Console initial values, exact storage identity and duplicate/malformed tables remain recorded debt.

Earlier validation and overlap notes

On earlier head a6e86fe483, hosted checks passed Windows and the relinker matrix; full Linux and pipe-write jobs were skipped. A Linux check of that head passed five checks plus the unload-retention skip, repeated three times; unload/reload was not exercised.

Original head a535212ecd: Windows production libraries/relinker and affected targets built; 9 focused CTests and 65 public-header tests passed. Original-main Shared/Binding controls failed. Four actual-source Linux component checks passed.

Follow-up 15f38f293b: both split Windows tests passed; the real-project registration audit passed (1825 executables). Linux components passed Shared/adoption/unload (3/3); a test-only NODELETE component passed Shared/adoption and skipped unload. These component results do not claim a full Linux product build. Historical skip-policy checks passed on Windows/Linux.

BunnyFl's review of f0252c7af0 reports five Windows environment checks passing and three expected negative-control failures. Later main integrations retain the original changes and maintainer commits.

#7715's initial-environment values are a real overlap, not a prerequisite; no combined runtime result or merge order is established. Earlier adjacent declarations, registrations and debt edits are retained. Historical results keep their tested heads/platforms.

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: n/a
  • AI-assisted: yes

@BunnyFl BunnyFl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The direction matches the console's design. In firmware 13.42, environ (+2thxYZ4syk) is a data export of libkernel.sprx (.data, 0x84278), and libSceLibcInternal.sprx (sha256 a01795ab49df639dd40abd6194956ada062244826824ce486c9acab227bf5285) imports it as an undefined data symbol. Its getenv (smbQukfxYJM, 0x74c00) loads the table through that import on every call, with no private copy (read from disassembly only, not measured on a console):

74c11: test rdi, rdi ; je ret-null
74c30..74c42: scan the name; '=' in the name -> return NULL
74c4a: mov rax, [rip+0x13de27]   ; GOT slot: &environ
74c51: mov r14, [rax]            ; environ
74c59: mov r12, [r14]            ; walk environ[i]

So making libc read and write libkernel's exported table, as this PR does, is how the console's libc behaves.

Build and test on Windows (WinLibs GCC, BUILD_TESTING=ON), PR merged into current main:

  • guest_environment_allocation, guest_environment_binding, guest_environment_shared, guest_environment, guest_execvp and guest_system_configuration pass.
  • With main's Environment.cpp, Process.cpp and General.hpp restored (the PR's Api.hpp declaration kept so the fixtures compile), guest_environment_binding and guest_environment_shared abort. guest_environment_allocation compiles Environment.cpp itself, so it has no main control.

I didn't check the composition with #7715's ASOBI_ROOT seed that the PR body mentions.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6149 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7447 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 7464 docs/dev/debt/libkernel.md
PR 7544 docs/dev/debt/libc.md
PR 7715 core/libs/prx/libc/src/Environment.cpp
docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8965 docs/dev/debt/libc.md
PR 9087 docs/dev/debt/libc.md
PR 9156 docs/dev/debt/libkernel.md
PR 9293 docs/dev/debt/libkernel.md
PR 9297 docs/dev/debt/libkernel.md
PR 9302 docs/dev/debt/libkernel.md
PR 9340 docs/dev/debt/libc.md
PR 9389 docs/dev/debt/libkernel.md
PR 9447 core/libs/prx/libc/include/General.hpp
docs/dev/debt/libc.md
PR 9466 docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 9557 docs/dev/debt/libkernel.md
PR 9566 docs/dev/debt/libkernel.md
PR 9938 docs/dev/debt/libkernel.md
PR 10409 docs/dev/debt/libc.md
PR 10442 docs/dev/debt/libkernel.md
PR 11172 docs/dev/debt/libc.md
PR 11215 core/libs/prx/libkernel/include/Api.hpp
docs/dev/debt/libkernel.md
PR 11332 docs/dev/debt/libc.md
PR 11628 docs/dev/debt/libkernel.md
PR 11661 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 11689 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 11698 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 11896 docs/dev/debt/libkernel.md
PR 12184 docs/dev/debt/libc.md
PR 12622 docs/dev/debt/libc.md
PR 12682 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 12688 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 12700 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 12849 docs/dev/debt/libc.md
PR 12965 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 14108 docs/dev/debt/libkernel.md
PR 15973 docs/dev/debt/libc.md
PR 16790 docs/dev/debt/libkernel.md
PR 16791 docs/dev/debt/libc.md
PR 17026 docs/dev/debt/libc.md
PR 17259 docs/dev/debt/libc.md
PR 17551 docs/dev/debt/libkernel.md
PR 17557 docs/dev/debt/libc.md
PR 17558 docs/dev/debt/libc.md
PR 17638 docs/dev/debt/libkernel.md
PR 18380 docs/dev/debt/libc.md
PR 18515 docs/dev/debt/libkernel.md
PR 19650 docs/dev/debt/libkernel.md
PR 20315 core/libs/prx/libc/include/General.hpp

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi lgqdaxia,

Reviewed at a535212ecd.

guest_environment_binding never gets past the first unload on Linux with GCC, so its unload/reload checks have not run there. At this head on a GCC 16.2 / glibc 2.44 build, ctest reports guest_environment_binding ... ***Skipped (exit 77, "skipped unload checks because the platform loader retained libkernel").

Cause: libkernel.prx exports 24 STB_GNU_UNIQUE objects (function-local statics such as _ZZN11HostMapping7QueryFdEvE2fd and _ZZ18LogTimestampMicrosvE7started). glibc marks any object that defines a unique symbol as NODELETE, so dlclose never unloads it. LD_DEBUG=files,bindings shows marking .../libkernel.prx [0] as NODELETE due to unique symbol on the first open. This is deterministic on every GCC build, not a flaky loader choice. Only Windows actually checks fallback detachment and reload (it passed there: Test #695: guest_environment_binding ... Passed).

A local check at this head: adding

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    target_compile_options(libkernel PRIVATE -fno-gnu-unique)
endif()

to core/libs/prx/libkernel/CMakeLists.txt leaves 0 UNIQUE symbols in libkernel.prx. The test then unloads and reloads libkernel and passes all of its checks (guest_environment_binding ... Passed, exit 0; guest_environment_shared and guest_environment_allocation still pass).

Could you either:

  1. build libkernel with -fno-gnu-unique on GCC (please check that no function-local static in libkernel must be shared with another module loaded with RTLD_LOCAL, since that is what GNU_UNIQUE protects); or
  2. if libkernel should stay as it is, make the unload part honest on Linux: keep the load/adoption checks as their own test, which always runs and passes or fails, and register the unload/reload part as a separate test that may skip. Then a Skipped result no longer hides the checks that did run.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head a535212 merged onto main a4eca2a · tested 2026-11-03 00:58 UTC · 34 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 3,486 passed · 15 failed (0 new, 13 also fail on main, 2 unstable on main) · 60 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 3,561 of 3,591 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (1313 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.7 s, ⚠️ agc_driver_graphics_maps_fallback 120.1 s, ⚠️ agc_driver_graphics 116.8 s, ⚠️ public_headers 63.8 s, ⚠️ agc_driver_bda_device 57.5 s
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_array_layer_target_cpu: failed in 1 of the last 6 main runs
agc_driver_pipeline_journal: failed in 4 of the last 6 main runs
Failing on main too (13, not counted against this PR)
agc_driver_guest_memory_lifetime_direct
agc_driver_image_table
agc_driver_job_manager_compute_capacity
agc_driver_native_depth_bda_clear
agc_driver_native_depth_buffer_clear
agc_driver_native_depth_clears
agc_driver_native_multisample_depth
agc_driver_submit_progress
agc_idle_publish_wait
agc_submit_progress
agc_submit_progress_no_timeline
guest_mmap_executable
guest_socket_options_multicast
Passed on retry (2, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)
agc_driver_graphics_maps_fallback: Timeout in the parallel run; also passed only on retry in 59 other runs in the last 7 days
agc_driver_store_pending_identity: Failed in the parallel run; also passed only on retry in 1 other runs in the last 7 days
Validated but not compared (1, not in the main baseline's validation pass)
guest_environment_binding
Validation IDs already present on main (4 IDs in 754 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (754 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_passes, agc_driver_address_passes_draw_transitions, agc_driver_address_passes_targets_split, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, and 746 more
VUID-vkCmdCopyImage-srcImage-01548 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_storage_dispatch, and 3 more
VUID-vkCmdCopyImage-srcImage-01551 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_storage_dispatch, and 3 more
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
Skipped (60)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_copied_writer_label_order_drain: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_image_table_vouched_lookups: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a watched imported table cannot be vouched for
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_driver_unit_shadow_budget: skipped, the device does not import watched host memory for unit shadows
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_shadowed_key_stores: skipped, the device imports no watched host memory under a unit shadow
agc_small_tiled_shadow_label: skipped, host imports are unavailable: the test block is not imported and watched
agc_storage_clear_hand_over: skipped, the device imports no watched host memory for the clear-key hand-over
agc_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_environment_binding: 
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no display
Reproduce
git fetch origin a535212ecd5b4b5faeec919885b676740decf95c a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8
git checkout a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8 && git merge --no-ff a535212ecd5b4b5faeec919885b676740decf95c
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@lgqdaxia

lgqdaxia commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for identifying the full-libkernel GCC loader behavior and testing the flag alternative. I took option 2 in 15f38f293ba1c0df43fe2193cff2ea71b420e9c4:

  • guest_environment_binding now checks libc-only setup, load/adoption and exported-table replacement independently, with no skip return code.
  • guest_environment_binding_unload runs the same prerequisite assertions, then checks detachment and reload. Only this test may return 77 when the loader retains libkernel. Both keep their 20-second timeouts.
  • The Linux skip audit accepts only this exact unload-test name with the exact loader-retention diagnostic. Windows retention, adoption skips, other names, missing reasons and additional unexpected skip reasons still fail the audit.

I left libkernel's production compiler options unchanged. Disabling GNU_UNIQUE would change static-object sharing beyond this environment fix, and I have not established the requested cross-module static audit.

Validation: the real Windows full-project Ninja configuration and registration audit pass (1,825 executables, zero registration gaps). The changed fixture was compiled against the unchanged, previously validated Windows libc/libkernel artifacts; both registered split CTests pass with no skips. This reused those artifacts rather than rebuilding production libraries. The skip-policy suite passes all 37 tests on Windows and Linux.

In WSL/GCC 13.3, actual-source Environment/Process component DSOs pass all three Shared/Binding/Unload tests when unloadable. A separate test-only -z,nodelete component variant reports adoption Passed and only unload Skipped; its real JUnit passes the narrow skip audit. Restoring the original main Environment/Process sources makes both binding tests fail their adoption assertion before any skip, even with NODELETE. These are component checks, not a full Linux production-libkernel build. Your full-libkernel GCC 16.2/24-UNIQUE observations remain external reviewer evidence; I am not claiming Linux full-product unload coverage.

@BunnyFl BunnyFl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of 15f38f293b (delta over my approval at a535212ecd): the adoption checks now sit in guest_environment_binding, which has no skip code. Only guest_environment_binding_unload keeps SKIP_RETURN_CODE 77. The tools/check_skips.py exception is narrow: it applies outside the Windows branch, only to that exact test name, and only when the one skipped line is the exact string printed at core/libs/tests/GuestEnvironmentBinding.cpp:74.

Windows 11, WinLibs GCC, merged onto current main:

  • PR: guest_environment_binding, guest_environment_binding_unload, check_skips and check_skips_ctest pass. The unload test ran rather than skipping.
  • Main's General.hpp, Environment.cpp, Process.cpp and libkernel Api.hpp restored: both binding tests abort (0xc0000409).

Not run here: Linux, the only platform where the loader-retention skip and its audit exception can trigger.

@BunnyFl

BunnyFl commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Correction to the last line of my approval: in CI the non-Windows check_skips.py audit runs only in the linux job (.github/workflows/build.yml:553), so that is where the audit exception applies. I haven't checked whether the loader-retention skip itself can occur on macOS. The approval stands.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head 15f38f2 merged onto main a4eca2a · tested 2026-11-03 02:47 UTC · 34 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 3,489 passed · 13 failed (0 new, 12 also fail on main, 1 unstable on main) · 60 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 3,562 of 3,591 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (1313 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.4 s, ⚠️ agc_driver_graphics 98.8 s, ⚠️ agc_driver_graphics_maps_fallback 93.2 s, ⚠️ unwrap_self 41.6 s, ⚠️ public_headers 38.5 s
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_pipeline_journal: failed in 5 of the last 7 main runs
Failing on main too (12, not counted against this PR)
agc_driver_guest_memory_lifetime_direct
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_depth_buffer_clear
agc_driver_native_depth_clears
agc_driver_native_multisample_depth
agc_driver_submit_progress
agc_idle_publish_wait
agc_submit_progress
agc_submit_progress_no_timeline
guest_mmap_executable
guest_socket_options_multicast
Validated but not compared (1, not in the main baseline's validation pass)
guest_environment_binding_unload
Validation IDs already present on main (4 IDs in 754 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (754 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_passes, agc_driver_address_passes_draw_transitions, agc_driver_address_passes_targets_split, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_array_layer_target, and 746 more
VUID-vkCmdCopyImage-srcImage-01548 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_storage_dispatch, and 3 more
VUID-vkCmdCopyImage-srcImage-01551 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_storage_dispatch, and 3 more
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
Skipped (60)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_copied_writer_label_order_drain: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_image_table_vouched_lookups: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a watched imported table cannot be vouched for
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_driver_unit_shadow_budget: skipped, the device does not import watched host memory for unit shadows
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_shadowed_key_stores: skipped, the device imports no watched host memory under a unit shadow
agc_small_tiled_shadow_label: skipped, host imports are unavailable: the test block is not imported and watched
agc_storage_clear_hand_over: skipped, the device imports no watched host memory for the clear-key hand-over
agc_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_environment_binding_unload: 
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_backtoback: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_controls: skipped, no 
Reproduce
git fetch origin 15f38f293ba1c0df43fe2193cff2ea71b420e9c4 a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8
git checkout a4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8 && git merge --no-ff 15f38f293ba1c0df43fe2193cff2ea71b420e9c4
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 4, 2026
@lgqdaxia
lgqdaxia force-pushed the codex/fix-guest-environment-coherence branch from 15f38f2 to 91bd22c Compare November 4, 2026 07:22
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 4, 2026
@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head 91bd22c merged onto main 5b1d381 · tested 2026-11-04 09:09 UTC · 42 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 3,779 passed · 14 failed (0 new, 11 also fail on main, 3 unstable on main) · 62 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 3,855 of 3,883 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (1381 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_pipeline_journal 120.3 s, ⚠️ agc_driver_graphics 112.2 s, ⚠️ agc_driver_graphics_maps_fallback 101.6 s, ⚠️ public_headers 72.8 s, ⚠️ agc_shader_sampler_limits 41.7 s
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_alpha_to_coverage_sample_mask_export: failed in 4 of the last 10 main runs
agc_driver_pipeline_journal: failed in 8 of the last 10 main runs
agc_driver_two_sample_alpha_to_coverage_sample_mask_export: failed in 3 of the last 10 main runs
Failing on main too (11, not counted against this PR)
agc_driver_guest_memory_lifetime_direct
agc_driver_image_table
agc_driver_job_manager_compute_capacity
agc_driver_native_depth_bda_clear
agc_driver_native_depth_buffer_clear
agc_driver_native_depth_clears
agc_driver_native_multisample_depth
agc_driver_submit_progress
agc_submit_progress
agc_submit_progress_no_timeline
guest_mmap_executable
Validated but not compared (1, not in the main baseline's validation pass)
guest_environment_binding_unload
Validation IDs already present on main (8 IDs in 799 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (799 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_passes, agc_driver_address_passes_draw_transitions, agc_driver_address_passes_targets_split, agc_driver_alias_copy_label, agc_driver_alpha_to_coverage, agc_driver_alpha_to_coverage_sample_mask_export, and 791 more
VUID-vkCmdCopyImage-srcImage-01548 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store_image_copy, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_partially_unmapped_plane, agc_driver_depth_plane_unmapped_plane, and 3 more
VUID-vkCmdCopyImage-srcImage-01551 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store_image_copy, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_partially_unmapped_plane, agc_driver_depth_plane_unmapped_plane, and 3 more
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
VUID-VkSamplerCreateInfo-addressModeU-01079 (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeU-parameter (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeV-parameter (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeW-parameter (1 test): agc_driver_image_gather_volume
Skipped (62)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_copied_writer_label_order_drain: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_image_table_vouched_lookups: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a watched imported table cannot be vouched for
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_driver_unit_shadow_budget: skipped, the device does not import watched host memory for unit shadows
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_idle_publish_wait: skipped, the device reports 4 of 4 host-imported pages written after a GPU read, so a forced watch of the import reads its submissions as CPU stores
agc_shadowed_key_stores: skipped, the device imports no watched host memory under a unit shadow
agc_small_tiled_shadow_label: skipped, host imports are unavailable: the test block is not imported and watched
agc_storage_clear_hand_over: skipped, the device imports no watched host memory for the clear-key hand-over
agc_storage_pending_key_refresh: skipped, refreshes over a pending key store are not testable here
agc_unit_shadow: skipped, the device does not import watched host memory for unit shadows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_environment_binding_unload: 
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or
Reproduce
git fetch origin 91bd22c9a0ee5b23da4ea65b5d1ce159406511b7 5b1d381d5ad5d9f923326b18479c3bd889cdd588
git checkout 5b1d381d5ad5d9f923326b18479c3bd889cdd588 && git merge --no-ff 91bd22c9a0ee5b23da4ea65b5d1ce159406511b7
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@lgqdaxia
lgqdaxia force-pushed the codex/fix-guest-environment-coherence branch from 91bd22c to 1e00648 Compare November 4, 2026 19:05

@BunnyFl BunnyFl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgqdaxia re-checked at 1e006482e7, still approved.

git range-diff against my last approval (15f38f293b): the test commit is identical, and in the fix commit only context lines moved, from the main changes it was rebased over (a neighbouring declaration in General.hpp, and the mergesort and select debt entries main rewrote). None of the PR's own +/- lines changed.

What I ran

Windows 11 Pro 10.0.26300, WinLibs GCC 15.2, Release, this head merged cleanly onto main b611e634f7 (2efb13e049):

  • guest_environment_allocation, guest_environment_binding, guest_environment_binding_unload, guest_environment_shared and guest_system_configuration: 5 of 5 pass.
  • Negative control: the same tree with core/libs/prx/libkernel/System/src/Process.cpp from main (the fixed empty environ) fails guest_environment_binding, guest_environment_binding_unload and guest_environment_shared (0xc0000409).
  • tools/tests/test_check_skips.py: 37 tests pass (run on main 9f35c937da + #15855 + this head).

Overlap

tools/pr_overlap.py --branch on this head:

  • Line overlaps it confirmed are all adjacent edits rather than the same change: #12970 registers its test next to guest_environment_shared in core/libs/prx/libkernel/CMakeLists.txt; #12750 and #14902 edit the same unexpected = ... line of tools/check_skips.py that this PR extends; #9161 touches the same line of tools/tests/test_check_skips.py.
  • The tool could not compare 78 PRs that conflict with main. I compared the ones that change this PR's code files (Environment.cpp, Process.cpp, General.hpp, Api.hpp, GuestSystemConfiguration.cpp): #5021, #7804, #11939, #13486, #14085, #9447 and #15781 change nothing environment-related there.
  • #7715 (renzipego-cpu) is the one real overlap: it seeds the initial entries of the guest environment in core/libs/prx/libc/src/Environment.cpp, which this PR rewrites. Whichever lands second has to redo its change on the other.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 6, 2026
@lgqdaxia
lgqdaxia force-pushed the codex/fix-guest-environment-coherence branch from 1e00648 to f0252c7 Compare November 6, 2026 16:52
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 6, 2026

@BunnyFl BunnyFl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lgqdaxia re-checked at f0252c7af0. The approval stands.

git range-diff against my last approval (1e006482e7): the test commit is identical. In the fix commit only a context line moved: main rewrote the neighbouring __progname entry in docs/dev/debt/libkernel.md, which is the line next to the environ entry this PR removes. None of the PR's own +/- lines changed.

What I ran

Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Release, this head merged onto current main (merge 8b59608b17, a clean auto-merge of docs/dev/debt/libkernel.md):

  • guest_environment_allocation, guest_environment_binding, guest_environment_binding_unload, guest_environment_shared and guest_system_configuration: 5 of 5 pass.
  • Negative control: the same tree with main's core/libs/prx/libkernel/System/src/Process.cpp fails guest_environment_binding, guest_environment_binding_unload and guest_environment_shared (0xc0000409); 2 of 5 pass.
  • tools/check_conventions.py --base upstream/main --head on this head: all checks pass.

Overlap

tools/pr_overlap.py --branch on this head gives the same picture as at 1e006482e7. The confirmed line overlaps are the adjacent tools/check_skips.py and tools/tests/test_check_skips.py edits of #12750, #14902 and #9161. #7715 still rewrites the guest environment's initial entries in core/libs/prx/libc/src/Environment.cpp and remains the one real overlap: whichever lands second has to redo its change on the other.

AI-assisted: yes (Claude Code)

@oneandonlydean oneandonlydean self-assigned this Nov 6, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 6, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi @lgqdaxia,

We merged current main into your branch (c4d53a7) so this can go ahead without another round. The only conflict was in tools/check_skips.py: main's new --json block is kept, and so are your loader-retention lines. Nothing else in your change was touched. The local build and the affected tests pass, and Windows CI is running again on the new head. Thanks for the change.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 8, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi @lgqdaxia,

Main moved again and the branch conflicted in core/libs/prx/libkernel/CMakeLists.txt: main added the instance lock tests at the same spot as your guest_environment_shared test. We merged current main (66db234b2d) in as 713cb242a3 and kept both blocks whole. No changes to your code. The guest_environment_shared and instance lock tests pass on the merged tree locally (10/10). Windows is re-running.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 8, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 8, 2026
@rudranshcoolhai-boop

Copy link
Copy Markdown
Contributor

Linux check of head a6e86fe483 (the PR head as is, base eb41c5465d; not merged onto current main).

Setup: Arch Linux x86-64, kernel 7.2.14-arch1-1, GCC 16.2.1 20260810, CMake 4.4.5, Ninja, Release, BUILD_TESTING=ON. Built guest_environment_allocation_tests, guest_environment_binding_tests, guest_environment_shared_tests and guest_system_configuration_tests.

ctest --test-dir build -R '^(guest_environment_(allocation|binding|binding_unload|shared)|guest_system_configuration|check_skips)$' --repeat until-fail:3 --output-on-failure --no-tests=error, 3 runs:

  • passed in each run: guest_environment_allocation, guest_environment_binding, guest_environment_shared, guest_system_configuration, check_skips (5 of 5)
  • guest_environment_binding_unload: Skipped (exit 77, SKIP_RETURN_CODE) in each run. Its output with ctest -R '^guest_environment_binding_unload$' -V:
environment binding: skipped unload checks because the platform loader retained libkernel; fallback detachment was not verified

So on this machine the loader-retention skip path is taken and the unload/reload checks do not run.

Not run: other libc and libkernel tests, the head merged onto current main, macOS, a title.

AI-assisted: yes.

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 9, 2026
@lgqdaxia
lgqdaxia force-pushed the codex/fix-guest-environment-coherence branch from 5d41187 to bd2dd42 Compare November 12, 2026 13:18
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 13, 2026
@oneandonlydean
oneandonlydean merged commit ff54ed4 into boykopovar:main Nov 15, 2026
21 of 25 checks passed
@lgqdaxia
lgqdaxia deleted the codex/fix-guest-environment-coherence branch November 28, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants