Skip to content

fix(agc): read the Darwin environment with _NSGetEnviron - #16796

Open
wanderingbug wants to merge 1 commit into
boykopovar:mainfrom
wanderingbug:cursor/macos-agc-environ-e22f
Open

wanderingbug wants to merge 1 commit into
boykopovar:mainfrom
wanderingbug:cursor/macos-agc-environ-e22f

Conversation

@wanderingbug

@wanderingbug wanderingbug commented Nov 7, 2026 •

Copy link
Copy Markdown

The device-fault report used ::environ. Apple's header exposes that name as a macro, so the qualified lookup is not a global, and the macOS loader publishes the process environment through _NSGetEnviron. Linux still reads ::environ.

What

Open #16801 (fix/macos-test-compile, 38bddbff44) edits only ResourceRequest.cpp, RtcpTransportFeedback.cpp, and GuestCesGbSetters.cpp: <initializer_list> and ResourceRequestBase value initialization. None of those symbols are in this pull request.

On Apple, VulkanDevice.cpp reads the process environment with _NSGetEnviron from <crt_externs.h>. Linux still uses ::environ.

Tested

The combined libs build compiled VulkanDevice.cpp with the overlay, and the MoltenVK square smoke later ran on the Apple M2 Max. Published a0e175fc0e is the same patch as tested 42f65a4b, replayed cleanly onto dd00a9c54e. That published SHA was not rebuilt on the Mac. The validation-layer comparison with main was not run. Not tested on a second machine; no game tested.

Checklist

  • Based on current main; no other open PR implements the same functions. Unchecked: parent is dd00a9c54e, and upstream main is now daad891ea6. test: build the RTCP feedback, CES setter and NKWebKit request tests on macOS #16801 does not implement these functions. Other open pull requests were not fully scanned.
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt. The diff adds no // comments.
  • Unimplemented paths throw. No new stub.
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source. No 3rdparty/ change.
  • Generic behaviour, not specific to one title
  • Depends on: none. Test-only feat(libkernel): process, thread and clock queries on macOS hosts #7804 and feat(libkernel): sceKernelRaiseException on macOS hosts #4630 were in the Mac tree and are not in this branch.
  • Fixes: none found in this pass. No issue search.
  • Unblocks: none claimed. No title bring-up check.
  • GPUs tested: the combined square smoke used Apple M2 Max, macOS 27.2, MoltenVK 1.4.2. Unchecked because this changes the AGC driver and the validation-layer comparison with main was not run on this head.
  • AI-assisted: yes

The device-fault report used ::environ. Apple's header exposes that
name as a macro, so the qualified lookup is not a global, and the
macOS loader publishes the process environment through _NSGetEnviron.
Linux still reads ::environ.

Co-authored-by: devindevsec <devindevsec@users.noreply.github.com>
@github-actions github-actions Bot added the agc libSceAgc* label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 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 1395 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4472 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 4847 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 7643 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9289 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9356 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9387 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 10867 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11435 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 11483 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 12828 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 12944 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 13148 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 13863 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 13929 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 15343 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 15548 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 16571 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 16953 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 17056 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 17611 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 17943 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 18029 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 18082 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 18173 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 18829 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 19557 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20030 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20111 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 20172 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 21211 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 21923 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22001 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22029 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22071 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22424 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22531 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22647 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 22697 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 24661 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 24714 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 25010 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 26686 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 28142 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 28193 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 28234 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 28387 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 28470 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 28487 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 28488 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 28590 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 28659 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 28673 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 28948 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29033 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29060 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29085 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29089 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29098 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29106 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29107 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29110 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29113 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29115 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29116 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29117 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29119 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29120 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29121 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
PR 29123 core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp

@gabichuuuuu gabichuuuuu 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.

Read a0e175fc0e. The device-fault environment dump now takes *_NSGetEnviron() on Apple, with <crt_externs.h> included under __APPLE__ only; Windows keeps _environ and Linux ::environ, so neither changes. One note: three other files in the same library read the environment through extern char** environ; and plain environ on every non-Windows host (FrameRecorder.cpp:29, HostReportSources.cpp:17, PerformanceTrace.cpp:29). If the macOS build accepts those, it's only the qualified ::environ spelling that breaks there; if not, they'd need the same treatment. Either way this change is fine.

AI-assisted: yes.

@adriadam10 adriadam10 self-assigned this Nov 11, 2026
@adriadam10

Copy link
Copy Markdown
Collaborator

Ready to merge from my side, but the PR description fails the conventions check:

  • [pr-template] Fill in the pull request template: unchecked: Based on current main; no other open PR implements the same functions. Unchecked: parent is dd00a9c54e, and upstream main is now daad891ea6. test: build the RTCP feedback, CES setter and NKWebKit request tests on macOS #16801 does not implement these functions. Other open pull requests were not fully scanned.
  • [pr-template] Fill in the pull request template: unchecked: Fixes: none found in this pass. No issue search.
  • [pr-template] Fill in the pull request template: unchecked: Unblocks: none claimed. No title bring-up check.
  • [pr-template] Fill in the pull request template: unchecked: GPUs tested: the combined square smoke used Apple M2 Max, macOS 27.2, MoltenVK 1.4.2. Unchecked because this changes the AGC driver and the validation-layer comparison with main was not run on this head.

Please fill those template lines in (only you can answer AI-assisted); it merges once they pass.

@MarcZX10 MarcZX10 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.

Reviewed — no blocking findings

Nothing blocks this; the points below are optional.

The change adds a macOS branch that reads the process environment through _NSGetEnviron, and the Windows and Linux branches stay as they were.

What I ran

  • Head a0e175fc0ef1267bc6efea3c985188e5774b253a, base main. Diff reviewed from the review folder; head source read with the repository reader. No build and no test was run.
  • Files: 1 reviewed (core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp), read only in part: the two changed hunks and the surrounding block. 0 excluded.
python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp 2540 2580
python3 repo_read.py search _NSGetEnviron
python3 repo_read.py search crt_externs.h

Results

Check Result Note
Darwin branch and include passed Matches the diff at head
Windows and Linux branches passed Unchanged
_NSGetEnviron use elsewhere passed Same pattern in other files
Comments added by the diff passed None
macOS build at head not run Author's build was on another SHA
Commands and raw output

repo_read.py search _NSGetEnviron

a0e175fc0ef1267bc6efea3c985188e5774b253a:core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp:2557:                        char** entries = *_NSGetEnviron();
a0e175fc0ef1267bc6efea3c985188e5774b253a:core/libs/prx/libSceLibcInternal/Spawn.cpp:454:        if (hostEnvironment == nullptr) hostEnvironment = *_NSGetEnviron();
a0e175fc0ef1267bc6efea3c985188e5774b253a:core/libs/prx/libSceSystemService/LoadExec.cpp:204:    const int error = posix_spawn(nullptr, target.c_str(), &actions, &attributes, pointers.data(), *_NSGetEnviron());
a0e175fc0ef1267bc6efea3c985188e5774b253a:core/libs/prx/libkernel/Pthread/src/MainThreadMacOs.cpp:162:    *_NSGetEnviron() = CopyStrings(*_NSGetEnviron());
4 matching lines at a0e175fc0ef1.

repo_read.py search crt_externs.h

a0e175fc0ef1267bc6efea3c985188e5774b253a:core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp:77:#include <crt_externs.h>
a0e175fc0ef1267bc6efea3c985188e5774b253a:core/libs/prx/libSceLibcInternal/Spawn.cpp:31:#include <crt_externs.h>
a0e175fc0ef1267bc6efea3c985188e5774b253a:core/libs/prx/libSceSystemService/LoadExec.cpp:25:#include <crt_externs.h>
a0e175fc0ef1267bc6efea3c985188e5774b253a:core/libs/prx/libc/src/RunReport.cpp:45:#include <crt_externs.h>
a0e175fc0ef1267bc6efea3c985188e5774b253a:core/libs/prx/libkernel/Pthread/src/MainThreadMacOs.cpp:6:#include <crt_externs.h>
a0e175fc0ef1267bc6efea3c985188e5774b253a:core/libs/prx/libkernel/System/src/MimallocRestart.cpp:12:#include <crt_externs.h>
a0e175fc0ef1267bc6efea3c985188e5774b253a:core/libs/tests/GuestMainStackMove.cpp:2:#include <crt_externs.h>
7 matching lines at a0e175fc0ef1.

repo_read.py cat core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp 2540 2580 (excerpt, lines 2554–2560 of the output)

2554 #ifdef _WIN32
2555                         char** entries = _environ;
2556 #elif defined(__APPLE__)
2557                         char** entries = *_NSGetEnviron();
2558 #else
2559                         char** entries = ::environ;
2560 #endif

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

  • Compilation of VulkanDevice.cpp for macOS at this head. The description says the build covered 42f65a4b, and the published a0e175fc0e was not rebuilt on the Mac.
  • The rest of VulkanDevice.cpp (6,562 lines). Only the changed lines and lines 2540–2580 were read. The file is listed under reviewed in the review folder, so the review is not complete for APPROVE; this is why the event is COMMENT.
  • Runtime behaviour of the environment dump on macOS. Nothing was run.
  • Linux and Windows builds. Those branches are unchanged code, but no build was run.

To get this to a good state

Nothing is required.

Optional:

  • Build the macOS target at a0e175fc0e and run the device-fault path once, so the published head has a build of its own and not only 42f65a4b.
  • Leave the unchecked checklist items as they are until that run exists.

@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head a0e175fc0e, applied with git apply (with -C1, context shifted) on main fd4aeed483 together with the other 28 PRs of one batch (#22366, #22943, #23994, #24150, #24483, #14625, #17425, #20528, #22589, #22887, #14505, #16792, #17900, #18484, #20048, #20099, #20517, #21636, #22886, #23659, #23880, #24047, #24100, #24248, #16353, #21683, #21714, #22276). All applied without conflicts and the whole tree built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
none: no test of its own in this PR - -

Whole batch: the full ctest -j 12 (6522 tests) on the RTX 3080 has 5 failing tests; the 4 that also fail on main fd4aeed483 are agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10. Intermittent in this run (pass when rerun alone, or known flaky): agc_driver_store_over_untracked. Failing tests I could not trace to a single PR (reverting the likely candidates did not clear them): public_headers. The 2125 agc_/video tests on the iGPU have 2 failing: agc_driver_stencil_plane_memory, agc_driver_store_over_untracked (agc_driver_stencil_plane_memory also fails on main).

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The trial merge onto c1601e56d5 was clean. The new include and _NSGetEnviron lookup are both guarded by __APPLE__, and the change is limited to device-fault reporting. Please confirm the exact current head compiles with the native Apple SDK, since running the existing Linux fault-report controls cannot cover Darwin’s declaration. I reviewed this path in source.

AI-assisted: yes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants