test(relinker): cover zero length and section overflow in eh_frame FDE record #14513

Merged
slopgobblercobbler merged 2 commits from upstream-pr/14513 into main 2026-11-05 23:15:58 +00:00
slopgobblercobbler commented 2026-11-01 15:22:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by slopgobblercobbler on 2026-11-01T15:22:39Z.


What

Add unit tests for .eh_frame FDE records with zero length and length overflowing remaining section size in core/relinker/relinker/tests/UnwindRecordBoundsTests.cpp.

Tested

Built and executed unwind_record_bounds_tests successfully (32 test cases passed). Ran conventions check tool with 0 findings.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5108726791 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14513). Originally posted by [slopgobblercobbler](https://github.com/slopgobblercobbler) on 2026-11-01T15:22:39Z. --- ### What Add unit tests for .eh_frame FDE records with zero length and length overflowing remaining section size in `core/relinker/relinker/tests/UnwindRecordBoundsTests.cpp`. ### Tested Built and executed `unwind_record_bounds_tests` successfully (32 test cases passed). Ran conventions check tool with 0 findings. ### 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: n/a - [x] AI-assisted: yes
BunnyFl commented 2026-11-02 01:26:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T01:26:42Z.

Review: DISMISSED


Both new cases pass for a different reason than the one they name, so they don't cover zero-length or overflowing FDEs.

Windows 11, WinLibs GCC 15.2.0 r7, relinker-only Release. Head 91fbd2bd9d merged into upstream/main 93dbd0f82a: unwind_record_bounds_tests prints 32 unwind record cases passed. I made catch (const std::exception&) print what(), and both cases throw:

fdeZeroRejected: Strict filter: unwind address is not file-backed
fdeOverflowRejected: Strict filter: unwind address is not file-backed

The cases reuse load and eh, but an earlier case in main() sets eh.MappedAddress = 0xFFFFFFFFFFFF0000ULL (line 76). So the reader rejects the .eh_frame_hdr address before it reaches the FDE at offset 96, and the length written there is never read. Because the catch accepts any exception, nothing notices.

Suggested fix, as #14573 does for its CIE cases: build fresh ProgramHeaders for these two cases, and check the message, e.g. Strict filter: unsupported FDE record size for length < 8 (EhFrameReader.cpp:210), and the section-bounds message for 1000. With that, disabling either check should make the test fail.

Note: .eh_frame defines a zero length field as the terminator. If the reader rejecting a zero length FDE is intended, a debt or test line saying so would help.

Also: #14513, #14527 and #14573 all replace the same std::cout << "30 unwind record cases passed\n"; line with different counts, so whichever merges second and third will conflict there.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5731230906 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14513#pullrequestreview-5731230906). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T01:26:42Z. **Review:** DISMISSED --- Both new cases pass for a different reason than the one they name, so they don't cover zero-length or overflowing FDEs. Windows 11, WinLibs GCC 15.2.0 r7, relinker-only Release. Head 91fbd2bd9d merged into upstream/main 93dbd0f82a: `unwind_record_bounds_tests` prints `32 unwind record cases passed`. I made `catch (const std::exception&)` print `what()`, and both cases throw: ``` fdeZeroRejected: Strict filter: unwind address is not file-backed fdeOverflowRejected: Strict filter: unwind address is not file-backed ``` The cases reuse `load` and `eh`, but an earlier case in `main()` sets `eh.MappedAddress = 0xFFFFFFFFFFFF0000ULL` (line 76). So the reader rejects the `.eh_frame_hdr` address before it reaches the FDE at offset 96, and the length written there is never read. Because the catch accepts any exception, nothing notices. Suggested fix, as #14573 does for its CIE cases: build fresh `ProgramHeader`s for these two cases, and check the message, e.g. `Strict filter: unsupported FDE record size` for `length < 8` (`EhFrameReader.cpp:210`), and the section-bounds message for 1000. With that, disabling either check should make the test fail. Note: `.eh_frame` defines a zero length field as the terminator. If the reader rejecting a zero length FDE is intended, a debt or test line saying so would help. Also: #14513, #14527 and #14573 all replace the same `std::cout << "30 unwind record cases passed\n";` line with different counts, so whichever merges second and third will conflict there.
MarcZX10 commented 2026-11-02 04:46:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T04:46:47Z.

Review: COMMENTED


Reviewed — no blocking findings

The two new rejections match the reader: an FDE record length below 8 is rejected as an unsupported FDE record size (EhFrameReader.cpp line 210), and a length that runs past the buffer is rejected by the range check (checkedRangeEnd, line 211). The test catches std::exception, so it passes for any rejection, including unrelated ones.

What I ran

  • Head 91fbd2bd9d53e49d08507fb96db41d1649b62d39; base f2d874c1fdccf781c0fa5d86619bb5dd8894b958. 1 file: core/relinker/relinker/tests/UnwindRecordBoundsTests.cpp (test-only; the existing test file already runs in the relinker jobs).
  • Read the full diff and the matching checks in core/relinker/relinker/src/analysis/UnusedNidFilter/EhFrameReader.cpp (lines 159-165 and 210-234 at base).
  • Read-only checks from the trusted main checkout (precheck not run: this session does not run code from PR heads): diff check, conventions, the ABI audit (no export changed) and the stack check.
  • Hosted: the relinker ubuntu g++, windows g++, asan and macOS jobs passed; the main windows job was skipped.
  • No MarcZX10 review at this head.

Results

Check Result Note
Diff check passed
Conventions and PR template passed conventions check from the main checkout
Mergeability and dependencies passed depends on none; the stack check passed
Zero-length FDE is rejected passed line 210
Overflowing FDE length is rejected passed the range check (line 211)
ABI audit (main-checkout tool) not applicable no exported symbol changed
Build and runtime tests not run no local build
Negative controls not run no local build
Hosted CI passed relinker jobs passed; the main windows job was skipped
Read-only check output

Precheck was not run: this session does not run code from PR heads. Hosted: gh api repos/boykopovar/AnyPS5/commits/91fbd2bd9d53e49d08507fb96db41d1649b62d39/check-runs.

Negative control

Not run here. A negative control needs a build, and code from this head is not run here.

Findings

Blocking

None.

Non-blocking

  • The new cases catch std::exception and do not check the message, so they would also pass for an unrelated failure. Asserting the "unsupported FDE record size" message for the zero case would pin the intended path.
  • This PR and #14527 and #14543 all change the same line ("30 unwind record cases passed") of UnwindRecordBoundsTests.cpp, so they will conflict when merged; one should land first and the others be rebased.

Sources

Not verified

  • Whether the relinker jobs run this test file was not confirmed.
  • The fixture layout (offsets in the test) was not traced beyond the reader's order.

To get this to a good state

  • Nothing blocking.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5732182681 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14513#pullrequestreview-5732182681). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T04:46:47Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The two new rejections match the reader: an FDE record length below 8 is rejected as an unsupported FDE record size (`EhFrameReader.cpp` line 210), and a length that runs past the buffer is rejected by the range check (`checkedRangeEnd`, line 211). The test catches `std::exception`, so it passes for any rejection, including unrelated ones. ## What I ran - Head `91fbd2bd9d53e49d08507fb96db41d1649b62d39`; base `f2d874c1fdccf781c0fa5d86619bb5dd8894b958`. 1 file: `core/relinker/relinker/tests/UnwindRecordBoundsTests.cpp` (test-only; the existing test file already runs in the relinker jobs). - Read the full diff and the matching checks in `core/relinker/relinker/src/analysis/UnusedNidFilter/EhFrameReader.cpp` (lines 159-165 and 210-234 at base). - Read-only checks from the trusted main checkout (precheck not run: this session does not run code from PR heads): diff check, conventions, the ABI audit (no export changed) and the stack check. - Hosted: the relinker ubuntu g++, windows g++, asan and macOS jobs passed; the main windows job was skipped. - No MarcZX10 review at this head. ## Results | Check | Result | Note | | --- | --- | --- | | Diff check | passed | | | Conventions and PR template | passed | conventions check from the main checkout | | Mergeability and dependencies | passed | depends on none; the stack check passed | | Zero-length FDE is rejected | passed | line 210 | | Overflowing FDE length is rejected | passed | the range check (line 211) | | ABI audit (main-checkout tool) | not applicable | no exported symbol changed | | Build and runtime tests | not run | no local build | | Negative controls | not run | no local build | | Hosted CI | passed | relinker jobs passed; the main windows job was skipped | <details><summary>Read-only check output</summary> Precheck was not run: this session does not run code from PR heads. Hosted: `gh api repos/boykopovar/AnyPS5/commits/91fbd2bd9d53e49d08507fb96db41d1649b62d39/check-runs`. </details> ## Negative control Not run here. A negative control needs a build, and code from this head is not run here. ## Findings **Blocking** None. **Non-blocking** - The new cases catch `std::exception` and do not check the message, so they would also pass for an unrelated failure. Asserting the "unsupported FDE record size" message for the zero case would pin the intended path. - This PR and #14527 and #14543 all change the same line ("30 unwind record cases passed") of `UnwindRecordBoundsTests.cpp`, so they will conflict when merged; one should land first and the others be rebased. ## Sources - Changed test: https://github.com/boykopovar/AnyPS5/blob/91fbd2bd9d53e49d08507fb96db41d1649b62d39/core/relinker/relinker/tests/UnwindRecordBoundsTests.cpp - Reader checks: https://github.com/boykopovar/AnyPS5/blob/f2d874c1fdccf781c0fa5d86619bb5dd8894b958/core/relinker/relinker/src/analysis/UnusedNidFilter/EhFrameReader.cpp#L159-L234 ## Not verified - Whether the relinker jobs run this test file was not confirmed. - The fixture layout (offsets in the test) was not traced beyond the reader's order. ## To get this to a good state - Nothing blocking.
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!14513
No description provided.