fix(tools): read the EnvironmentNumber environment reader in env_reference #8995

Merged
dantdmdarealguy merged 1 commit from upstream-pr/8995 into main 2026-10-23 23:40:39 +00:00
dantdmdarealguy commented 2026-10-21 09:01:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by dantdmdarealguy on 2026-10-21T09:01:49Z.


What

docs/dev/ENVIRONMENT.md is meant to list every APS5_* and ANYPS5_* name the code reads, and tools/env_reference.py with the env-reference rule of check_conventions.py keeps it complete. The Windows crash report reads APS5_CRASH_STACK_BYTES through its EnvironmentNumber helper (core/libs/prx/libc/src/specifics/windows/CrashReport.cpp L259-267, added by 127ee82f0). env_reference.py does not know that reader, so the name has no row in ENVIRONMENT.md and neither check reports it. Only USAGE.md names it.

env_reference.py now recognizes EnvironmentNumber("<name>") as an integer reader, in its forms and in the git grep pattern that check_conventions.py uses. ENVIRONMENT.md gets the APS5_CRASH_STACK_BYTES row in the libc table, and its list of readers now includes EnvironmentNumber. The row's description follows the code: the value is decimal or 0x hexadecimal, capped at 1048576 bytes, and 0 or unset prints nothing. test_env_reference.py gets an EnvironmentNumber read, expected as an integer with no default, and a MyEnvironmentNumber(...) call that must not count as a read.

Tested

Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Release build with BUILD_TESTING=ON.

  • python tools/tests/test_env_reference.py: on unmodified main with the new test file, FAILED (failures=1), Items in the second set but not the first: 'APS5_CRASH_STACK_BYTES'. With this change: Ran 8 tests ... OK.
  • python tools/env_reference.py --check: on main the output does not mention APS5_CRASH_STACK_BYTES. With the new row but main's env_reference.py, it reports APS5_CRASH_STACK_BYTES has a row in docs/dev/ENVIRONMENT.md but the code no longer reads it. With this change it reports no error about the name. On main and on this branch it still reports APS5_NO_WGI, which #8657 documents.
  • ctest --test-dir build --output-on-failure --timeout 120 --parallel 2 -R "^(env_reference|conventions_env_reference|windows_crash_stack_words|windows_crash_without_stack_words|patched_libraries)$": 5/5 passed, 357 patched libraries loaded, 0 failed.
  • To check the row against the code, the crash fixture tests/windows_backtrace_report_tests.exe fault was run with build/core/libs/libs/unpatched on PATH:
    • APS5_CRASH_STACK_BYTES=256 and =0x100: stack words from rsp ... (APS5_CRASH_STACK_BYTES): followed by 8 rows of 4 words (256 bytes).
    • =0 and unset: no stack words.
  • python tools/check_conventions.py --base origin/main: All conventions checks passed.
  • python tools/check_test_registration.py build: 1153 test executable(s), 0 built and not run as recorded, none new.
  • python tools/pr_overlap.py --branch agent/envsweep reports no overlap with the PRs it could compare. It could not compare 14 PRs that change ENVIRONMENT.md and conflict with main (#5431, #6186, #6636, #6879, #6924, #6946, #6947, #7484, #7604, #7642, #8077, #8246, #8484, #8971). None of their diffs mention APS5_CRASH_STACK_BYTES, EnvironmentNumber or the readers paragraph.

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, some AI assistance was used
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4949065255 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8995). Originally posted by [dantdmdarealguy](https://github.com/dantdmdarealguy) on 2026-10-21T09:01:49Z. --- ### What `docs/dev/ENVIRONMENT.md` is meant to list every `APS5_*` and `ANYPS5_*` name the code reads, and `tools/env_reference.py` with the env-reference rule of `check_conventions.py` keeps it complete. The Windows crash report reads `APS5_CRASH_STACK_BYTES` through its `EnvironmentNumber` helper (`core/libs/prx/libc/src/specifics/windows/CrashReport.cpp` L259-267, added by `127ee82f0`). `env_reference.py` does not know that reader, so the name has no row in ENVIRONMENT.md and neither check reports it. Only USAGE.md names it. `env_reference.py` now recognizes `EnvironmentNumber("<name>")` as an integer reader, in its forms and in the `git grep` pattern that `check_conventions.py` uses. ENVIRONMENT.md gets the `APS5_CRASH_STACK_BYTES` row in the libc table, and its list of readers now includes `EnvironmentNumber`. The row's description follows the code: the value is decimal or `0x` hexadecimal, capped at 1048576 bytes, and 0 or unset prints nothing. `test_env_reference.py` gets an `EnvironmentNumber` read, expected as an integer with no default, and a `MyEnvironmentNumber(...)` call that must not count as a read. ### Tested Windows 11 Pro, Intel Core i9-14900K, 128 GB RAM, NVIDIA GeForce RTX 5080 (driver 32.0.16.1742), WinLibs GCC 15.2.0, Release build with `BUILD_TESTING=ON`. - `python tools/tests/test_env_reference.py`: on unmodified `main` with the new test file, `FAILED (failures=1)`, `Items in the second set but not the first: 'APS5_CRASH_STACK_BYTES'`. With this change: `Ran 8 tests ... OK`. - `python tools/env_reference.py --check`: on `main` the output does not mention `APS5_CRASH_STACK_BYTES`. With the new row but `main`'s `env_reference.py`, it reports `APS5_CRASH_STACK_BYTES has a row in docs/dev/ENVIRONMENT.md but the code no longer reads it`. With this change it reports no error about the name. On `main` and on this branch it still reports `APS5_NO_WGI`, which #8657 documents. - `ctest --test-dir build --output-on-failure --timeout 120 --parallel 2 -R "^(env_reference|conventions_env_reference|windows_crash_stack_words|windows_crash_without_stack_words|patched_libraries)$"`: 5/5 passed, `357 patched libraries loaded, 0 failed`. - To check the row against the code, the crash fixture `tests/windows_backtrace_report_tests.exe fault` was run with `build/core/libs/libs/unpatched` on `PATH`: - `APS5_CRASH_STACK_BYTES=256` and `=0x100`: `stack words from rsp ... (APS5_CRASH_STACK_BYTES):` followed by 8 rows of 4 words (256 bytes). - `=0` and unset: no stack words. - `python tools/check_conventions.py --base origin/main`: `All conventions checks passed.` - `python tools/check_test_registration.py build`: `1153 test executable(s), 0 built and not run as recorded, none new`. - `python tools/pr_overlap.py --branch agent/envsweep` reports no overlap with the PRs it could compare. It could not compare 14 PRs that change ENVIRONMENT.md and conflict with `main` (#5431, #6186, #6636, #6879, #6924, #6946, #6947, #7484, #7604, #7642, #8077, #8246, #8484, #8971). None of their diffs mention `APS5_CRASH_STACK_BYTES`, `EnvironmentNumber` or the readers paragraph. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: n/a - [x] AI-assisted: yes, some AI assistance was used
xXPBSXx commented 2026-10-21 09:45:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T09:45:58Z.


Linux data point for 103484d0be: WSL2 Ubuntu 24.04 (a virtualised kernel, not bare-metal Linux), Python 3.12, PR head alone (not merged onto main), python3 -I -m unittest discover -s tools/tests -p test_env_reference.py.

  • With the PR: 8 tests OK.
  • With tools/env_reference.py restored to the merge-base (the PR's tests kept): 1 failure (test_reads_find_every_reader_form_and_ignore_other_names).
    Not tested: macOS, Windows, a merge onto current main.
    AI-assisted (Claude Code).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312974094 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8995#issuecomment-6312974094). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-21T09:45:58Z. --- Linux data point for `103484d0be`: WSL2 Ubuntu 24.04 (a virtualised kernel, not bare-metal Linux), Python 3.12, PR head alone (not merged onto `main`), `python3 -I -m unittest discover -s tools/tests -p test_env_reference.py`. - With the PR: 8 tests OK. - With `tools/env_reference.py` restored to the merge-base (the PR's tests kept): 1 failure (test_reads_find_every_reader_form_and_ignore_other_names). Not tested: macOS, Windows, a merge onto current `main`. AI-assisted (Claude Code).
harisibrar1 commented 2026-10-21 14:08:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-21T14:08:26Z.

Review: APPROVED


Verified on Windows 11, Python 3.14, merged onto main 80565c594:

  • python tools/tests/test_env_reference.py: 8 tests OK; python tools/tests/test_check_conventions_env_reference.py: 9 tests OK (merged and at the PR head).
  • Negative control on the merged tree with main's tools/env_reference.py: test_env_reference.py fails (failures=1), so the new fixture lines catch the change.
  • python tools/env_reference.py --check on the merged tree: the only error is the existing APS5_NO_WGI (#8657). APS5_CRASH_STACK_BYTES is detected and documented, and nothing else is newly reported.
  • EnvironmentNumber has one definition and one call site in core/ (CrashReport.cpp:259 and :267); no other unrecognized APS5_*/ANYPS5_* reader turned up. The other matching calls are test-side setters.
  • The new pattern accepts ns::EnvironmentNumber("...") and padded parentheses and rejects MyEnvironmentNumber/EnvironmentNumberOr. Like the existing readers it does not see templated calls, calls split across lines or a second argument, which is fine for the single call site.
  • Optional wording nit: strtoull(text, nullptr, 0) also parses a leading 0 as octal, so APS5_CRASH_STACK_BYTES=0400 means 256 bytes; the row could say "decimal, 0x hexadecimal or 0-prefixed octal".
  • python tools/check_conventions.py: passes.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5601041390 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8995#pullrequestreview-5601041390). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-21T14:08:26Z. **Review:** APPROVED --- Verified on Windows 11, Python 3.14, merged onto main 80565c594: - `python tools/tests/test_env_reference.py`: 8 tests OK; `python tools/tests/test_check_conventions_env_reference.py`: 9 tests OK (merged and at the PR head). - Negative control on the merged tree with main's `tools/env_reference.py`: `test_env_reference.py` fails (failures=1), so the new fixture lines catch the change. - `python tools/env_reference.py --check` on the merged tree: the only error is the existing `APS5_NO_WGI` (#8657). `APS5_CRASH_STACK_BYTES` is detected and documented, and nothing else is newly reported. - `EnvironmentNumber` has one definition and one call site in core/ (`CrashReport.cpp:259` and `:267`); no other unrecognized `APS5_*`/`ANYPS5_*` reader turned up. The other matching calls are test-side setters. - The new pattern accepts `ns::EnvironmentNumber("...")` and padded parentheses and rejects `MyEnvironmentNumber`/`EnvironmentNumberOr`. Like the existing readers it does not see templated calls, calls split across lines or a second argument, which is fine for the single call site. - Optional wording nit: `strtoull(text, nullptr, 0)` also parses a leading `0` as octal, so `APS5_CRASH_STACK_BYTES=0400` means 256 bytes; the row could say "decimal, 0x hexadecimal or 0-prefixed octal". - `python tools/check_conventions.py`: passes. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
THEMANnt commented 2026-10-23 14:52:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-23T14:52:13Z.

Review: APPROVED


Reviewed head 103484d0be3e359f2fe577af09b4bf59ca61b7eb.

On Windows with Python 3.11.9, baseline, pristine PR and candidate each passed 8 env_reference tests and 9 conventions tests. Whitespace and conventions checks passed. The old-code/new-tests control failed the expected assertion for discovering APS5_CRASH_STACK_BYTES.

EnvironmentNumber is recognized as an integer reader. Its specific reader regex uses a word boundary to exclude names such as MyEnvironmentNumber; it is also included in the broader GREP prefilter. The documentation row matches the inspected Windows helper and stack-reporting caller, including default 0 and the 1 MiB cap.

This was Python test execution and static source verification; the native crash handler was not built or executed. No actionable findings in the reviewed scope.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5630032390 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8995#pullrequestreview-5630032390). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-23T14:52:13Z. **Review:** APPROVED --- Reviewed head `103484d0be3e359f2fe577af09b4bf59ca61b7eb`. On Windows with Python 3.11.9, baseline, pristine PR and candidate each passed 8 env_reference tests and 9 conventions tests. Whitespace and conventions checks passed. The old-code/new-tests control failed the expected assertion for discovering `APS5_CRASH_STACK_BYTES`. `EnvironmentNumber` is recognized as an integer reader. Its specific reader regex uses a word boundary to exclude names such as `MyEnvironmentNumber`; it is also included in the broader GREP prefilter. The documentation row matches the inspected Windows helper and stack-reporting caller, including default 0 and the 1 MiB cap. This was Python test execution and static source verification; the native crash handler was not built or executed. No actionable findings in the reviewed scope.
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!8995
No description provided.