Repository navigation
fix(tools): reject invalid COFF inline name padding - #14331
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
The change rejects inline COFF short names with nonzero bytes after their first NUL, and the three malformed-padding cases fail on base, so the new check is exercised; I found no blocking issue, only two non-blocking notes.
What I ran
Exact head f276d27a7d67b17156b86c982a72f419eb276705, base 26fa1212b82f76dd49cf12d65e445d6ff3e0844c (current main). The merge preview against that base is clean.
Environment: Debian GNU/Linux 12 host, Python from the precheck interpreter /marc/Conlyse-VIEJO/.venv/bin/python3. No project build and no C++ compile or CTest run. The Python unit suite ran on Linux (the author's Windows run is not repeated here).
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14331
python3 -I tools/pr_test_quality.py --root <git archive of f276d27a7d67, tools/ only> --json tools/symbolize_samples.py tools/tests/test_symbolize_samples.pyThe precheck's test-quality step failed only because the helper is absent from the head tree. I ran the same helper by hand on an archive of the head's tools/ files; it reported zero findings.
Results
| Check | Result |
|---|---|
git diff --check against base |
passed |
| conventions and PR template | passed |
py_compile tools/symbolize_samples.py |
passed |
python -m unittest tools.tests.test_symbolize_samples |
passed, 40 tests, 2 skipped on Linux |
test registration (check_test_registration.py --scripts) |
passed |
merge preview against current base (pr_stack_check.py) |
clean |
| test-quality heuristic, run by hand | 0 findings |
| hosted CI at review time | eligibility, conventions, intake and labels queued; not complete |
Unedited unittest output (precheck, Linux)
..................................s...s.
----------------------------------------------------------------------
Ran 40 tests in 0.972s
OK (skipped=2)
Negative control
| Assertion | Change to the code under test | New test failed? |
|---|---|---|
test_coff_short_names_reject_nonzero_bytes_after_the_terminator (three padding cases) |
Base code (name.rstrip(b"\0")) |
Yes: three failures, ValueError not raised |
The valid controls in test_coff_full_width_and_padded_utf8_names_remain_supported pass on the head.
Findings
Blocking: none.
Non-blocking:
- Failure granularity. A bad name on an emitted code symbol makes
PeModuleraise for the whole module. The callers catch that and leave every frame of that module unsymbolized (symbolize_samples.pyL193-L195 at the head). That matches the file's other COFF checks, so I am not asking for a change. The PR body should say that the rejection is per module, not per symbol, so a reader does not expect one bad name to be skipped. - Test name.
test_coff_full_width_and_padded_utf8_names_remain_supporteddoes not test a full-width character. It covers a name that fills all eight bytes (caféplusabc) and a NUL-paddedcafé. A name such as..._exact_eight_bytes_and_padded_utf8_names_remain_supportedwould match what it checks.
Sources
- Head implementation:
AnyPS5/tools/symbolize_samples.py
Lines 109 to 112 in f276d27
- Caller fallback:
AnyPS5/tools/symbolize_samples.py
Lines 193 to 195 in f276d27
- New test:
AnyPS5/tools/tests/test_symbolize_samples.py
Lines 306 to 315 in f276d27
The padding rule itself comes from the PR body's citation of the Microsoft PE/COFF ShortName contract. I did not re-read that specification here.
Not verified
- The Windows unit run cited in the PR body was not repeated.
- The PE/COFF specification wording was not re-checked.
- No game, runtime, or console behaviour was tested, and none is claimed.
- Hosted CI jobs were still queued when reviewed.
MarcZX10
left a comment
There was a problem hiding this comment.
Re-checked — same head, looks good
The exact reviewed head remains f276d27a7d67b17156b86c982a72f419eb276705; the new COFF padding validation and its registered Python tests have no blocking findings.
What I ran
The earlier exact-head review ran tools/pr_precheck.py, Python syntax validation, the 40-test tools.tests.test_symbolize_samples suite (40 passed, 2 skipped on Linux), test registration checks, and the test-quality heuristic. No project build or C++ compile was run. The hosted Ubuntu and Windows relinker checks and ASan check have since passed; two macOS relinker jobs remain pending and do not exercise the changed Python tool.
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14331
python3 -m unittest tools.tests.test_symbolize_samples
python3 tools/check_test_registration.py --scriptsResults
| Check | Result |
|---|---|
| Python unit tests | 40 passed, 2 skipped on Linux |
| Conventions and registration | Passed |
| Hosted Ubuntu/Windows relinker and ASan | Passed |
| Hosted macOS relinker jobs | Pending; unrelated to changed Python tool |
Not verified
The author's Windows Python run is not independently repeated here. No game, runtime, or console behavior was tested.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings; a COFF short name with bytes after its terminator is now rejected, and the Ubuntu symbolize test passed
This PR makes tools/symbolize_samples.py reject a COFF inline symbol name when the bytes after its first NUL are not all zero. The old code stripped trailing NULs and kept whatever came before; the new code splits at the first NUL and checks the rest. The Ubuntu relinker job ran the tool's test file as CTest symbolize_samples, and it passed. I read the production change in full.
What I ran
- Head
c4e2ad6ffd777ffcc7b8f2e6be7f41d1dcefb40b; base26fa1212b82f76dd49cf12d65e445d6ff3e0844c. 2 files, +26/-1:tools/symbolize_samples.py(+3/-1) andtools/tests/test_symbolize_samples.py(+23). - Read the production change in full.
text, terminator, padding = name.partition(b"\0"). If a terminator exists andpaddinghas any non-NUL byte, the function raisesValueError. A name with no NUL is unchanged. - Test file: read the added method names only; test bodies not read.
- Hosted: the Ubuntu relinker job's CTest
symbolize_samples(Test #167) passed in a run of 554 of 554. The macOS clang, macOS x86_64, Ubuntu and Windows relinkers and relinker-asan succeeded. Windows check-run skipped. - Read-only checks from the trusted main checkout: diff check and conventions passed. ABI audit not applicable. Stack check: clean, no declared dependencies, no errors.
- No MarcZX10 review at this head.
Results
| Check | Result | Note |
|---|---|---|
| Diff check | passed | |
| Conventions and PR template | passed | the latest run succeeded; an earlier run was cancelled |
| Mergeability and dependencies | passed | stack check: clean; no declared dependencies |
| ABI audit | not applicable | no export changed |
symbolize_samples (hosted, Ubuntu relinker job) |
passed | Test #167 |
| Relinkers and relinker-asan (hosted) | passed | all succeeded |
| Production change (read) | passed by reading | the partition and the padding check are as described; no blocking defect found |
Test bodies in test_symbolize_samples.py |
not verified | names only |
| Negative controls | not run | no local build; no PR-head Python runs here |
Read-only check output
Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: not applicable. Stack check: clean, no declared dependencies, no errors. Hosted: gh api repos/boykopovar/AnyPS5/commits/c4e2ad6ffd777ffcc7b8f2e6be7f41d1dcefb40b/check-runs, and the Ubuntu relinker job log (554 of 554).
Negative control
Not run here. A negative control needs a local run of the symbolizer tests on a crafted COFF name, and no PR-head Python runs on this machine.
Findings
Blocking
None from the code read.
Non-blocking
- The old code stripped every trailing NUL, and the new code rejects non-NUL bytes after the first NUL. A real COFF file that puts junk after a terminator would now fail the whole symbolization run rather than be read. The PR does not say whether any real input is affected. That was not checked here.
Sources
- Production: https://github.com/boykopovar/AnyPS5/blob/c4e2ad6ffd777ffcc7b8f2e6be7f41d1dcefb40b/tools/symbolize_samples.py
- Tests: https://github.com/boykopovar/AnyPS5/blob/c4e2ad6ffd777ffcc7b8f2e6be7f41d1dcefb40b/tools/tests/test_symbolize_samples.py
- Ubuntu relinker job log: the
relinker (ubuntu-latest, g++)check-run on c4e2ad6
Not verified
- The test bodies in
test_symbolize_samples.py. - Whether any real COFF input has bytes after the terminator.
To get this to a good state
- Nothing blocking. Say in the PR body whether a real input can have bytes after the terminator, and what the tool should do then.
What
Reject inline COFF symbol names with nonzero bytes after their first NUL, following the Microsoft PE/COFF ShortName padding contract. A malformed name rejects the whole module for symbolization, so all of that module’s frames remain unsymbolized. Previously junk became part of the sampled symbol name. Exactly eight-byte names and correctly NUL-padded UTF-8 names remain supported.
The regression inputs are synthetic malformed COFF fixtures; no real-title reproduction was performed for this change. Nonzero bytes after the first NUL violate the inline ShortName padding contract, so the tool rejects that module and preserves its frames rather than inventing a symbol name.
Tested
Windows, Python 3.12: full symbolize_samples suite, 40 tests (39 passed, 1 platform skip). Three malformed-padding regression cases fail on main. Valid eight-byte and padded UTF-8 controls pass. check_conventions.py --base origin/main and git diff --check pass. Official pr_overlap.py comparison of 1,602 open PR heads reports no overlap (public REST snapshot transport; unchanged comparison logic with exact-base probe caching).
Base: 26fa121. Published c4e2ad6 has the tested local tree 2d71c8737f11ef5ae47632e3e94bcf9a8b095030. No runtime/game test claim.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)