ci: run the relinker TLS coverage tests under AddressSanitizer #7097

Merged
inmert merged 1 commit from upstream-pr/7097 into main 2026-10-17 20:42:42 +00:00
inmert commented 2026-10-17 11:20:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by inmert on 2026-10-17T11:20:46Z.


What

Fixes #7062. #6401 (MarcZX100) fixed a 1-byte read past the end of the input in WindowsTlsBuilder and added the segment-prefix-at-eof case to the TLS coverage tests, but as Dextroid17 showed there, that case only catches the bug when the relinker is built with AddressSanitizer, and no CI job did that.

This adds a relinker-asan job next to relinker. It runs under the same condition, merges the pull request into main the same way, builds the relinker alone in Debug with -DANYPS5_ENABLE_ASAN=ON, and runs the tls_function_coverage label (31 tests) with --no-tests=error, so the job also fails if the label ever stops matching.

It has to be Debug. With -DCMAKE_BUILD_TYPE=Release and ASan, all 31 tests still pass with the #6401 fix reverted: at -O3 GCC no longer emits the stray load (its result is only used when address is set), so there is nothing for ASan to catch. In a Debug build the same revert fails tls_function_coverage_rejected:

ERROR: AddressSanitizer: heap-buffer-overflow
READ of size 1 ... in Elfpatcher::Windows::WindowsTlsBuilder::Build ... WindowsTlsBuilder.cpp:152
0 bytes after 8192-byte region ... allocated by ... Io::FileReader::Read

I also tried the whole relinker set under ASan (187 tests, about 95 s here). Everything passes except guest_module_args, guest_module_fini and guest_deferred_dependencies, which load the ASan-built output into a plain Python process and stop with "ASan runtime does not come first in initial library list". That is the test harness, not a finding, so the job keeps to the TLS label as the issue asks. The other suites can be added once those three run with the runtime preloaded.

Tested

Ubuntu 24.04, GCC 13.3.0, on main 864729dc0, with the commands the job runs:

  • Debug + ASan, ctest --label-regex '^tls_function_coverage$' --no-tests=error: 31/31 pass, about 20 s.
  • The same with WindowsTlsBuilder.cpp put back to its state before #6401: tls_function_coverage_rejected fails with the report above, the other 30 pass.
  • Release + ASan with the fix reverted: 31/31 pass, which is why the job builds Debug.
  • python3 tools/check_conventions.py --base origin/main passes.
  • Not tested: the workflow itself on GitHub; this PR's own run is its first, since the relinker jobs also run when build.yml changes.

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: Fixes #7062
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4899625743 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7097). Originally posted by [inmert](https://github.com/inmert) on 2026-10-17T11:20:46Z. --- ### What Fixes #7062. #6401 (MarcZX100) fixed a 1-byte read past the end of the input in `WindowsTlsBuilder` and added the `segment-prefix-at-eof` case to the TLS coverage tests, but as Dextroid17 showed there, that case only catches the bug when the relinker is built with AddressSanitizer, and no CI job did that. This adds a `relinker-asan` job next to `relinker`. It runs under the same condition, merges the pull request into `main` the same way, builds the relinker alone in Debug with `-DANYPS5_ENABLE_ASAN=ON`, and runs the `tls_function_coverage` label (31 tests) with `--no-tests=error`, so the job also fails if the label ever stops matching. It has to be Debug. With `-DCMAKE_BUILD_TYPE=Release` and ASan, all 31 tests still pass with the #6401 fix reverted: at -O3 GCC no longer emits the stray load (its result is only used when `address` is set), so there is nothing for ASan to catch. In a Debug build the same revert fails `tls_function_coverage_rejected`: ``` ERROR: AddressSanitizer: heap-buffer-overflow READ of size 1 ... in Elfpatcher::Windows::WindowsTlsBuilder::Build ... WindowsTlsBuilder.cpp:152 0 bytes after 8192-byte region ... allocated by ... Io::FileReader::Read ``` I also tried the whole relinker set under ASan (187 tests, about 95 s here). Everything passes except `guest_module_args`, `guest_module_fini` and `guest_deferred_dependencies`, which load the ASan-built output into a plain Python process and stop with "ASan runtime does not come first in initial library list". That is the test harness, not a finding, so the job keeps to the TLS label as the issue asks. The other suites can be added once those three run with the runtime preloaded. ### Tested Ubuntu 24.04, GCC 13.3.0, on `main` `864729dc0`, with the commands the job runs: - Debug + ASan, `ctest --label-regex '^tls_function_coverage$' --no-tests=error`: 31/31 pass, about 20 s. - The same with `WindowsTlsBuilder.cpp` put back to its state before #6401: `tls_function_coverage_rejected` fails with the report above, the other 30 pass. - Release + ASan with the fix reverted: 31/31 pass, which is why the job builds Debug. - `python3 tools/check_conventions.py --base origin/main` passes. - Not tested: the workflow itself on GitHub; this PR's own run is its first, since the relinker jobs also run when `build.yml` changes. ### 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: Fixes #7062 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-17 11:27:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T11:27:37Z.


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 6044 .github/workflows/build.yml
PR 7096 .github/workflows/build.yml
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233344712 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7097#issuecomment-6233344712). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-17T11:27:37Z. --- <!-- pr-overlap --> 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 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `.github/workflows/build.yml` | | [PR 7096](https://www.github.com/boykopovar/AnyPS5/pull/7096) | `.github/workflows/build.yml` |
MarcZX10 commented 2026-10-17 13:16:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T13:16:36Z.


I compared the overlapping #7096 PR and ran its current check result. Both add an ASan build and tls_function_coverage run for this issue; #7096 places those steps in the existing Linux relinker job and its hosted run completed 31/31 TLS coverage tests successfully. This PR adds a separate Ubuntu job that rebuilds the relinker and manually replays the PR merge setup already performed by the existing workflow. Could you coordinate with @pushkarreddyy on consolidating into #7096, or explain a required behavior that #7096 does not cover? I’d avoid landing both paths because that would duplicate the ASan build and test cost on each relinker change.

AI-assisted: yes (Codex); comparison and check result reviewed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6234332553 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7097#issuecomment-6234332553). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T13:16:36Z. --- I compared the overlapping #7096 PR and ran its current check result. Both add an ASan build and `tls_function_coverage` run for this issue; #7096 places those steps in the existing Linux relinker job and its hosted run completed 31/31 TLS coverage tests successfully. This PR adds a separate Ubuntu job that rebuilds the relinker and manually replays the PR merge setup already performed by the existing workflow. Could you coordinate with @pushkarreddyy on consolidating into #7096, or explain a required behavior that #7096 does not cover? I’d avoid landing both paths because that would duplicate the ASan build and test cost on each relinker change. AI-assisted: yes (Codex); comparison and check result reviewed.
pushkarreddyy commented 2026-10-17 13:21:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-17T13:21:11Z.


Thanks @MarcZX100 for the thorough comparison and review!

Hi @inmert — happy to coordinate on this! As Marc noted, #7096 integrates the ASan build and test execution directly into the existing Linux relinker matrix step, avoiding spinning up a separate runner and duplicate build setup while verifying all 31/31 TLS function coverage tests.

I have just rebased #7096 cleanly onto latest origin/main (04788b090). If there are any specific flags, additional test steps, or refinements from your PR you would like to see incorporated, please let me know and I'm very happy to add them to #7096 so we have the best combined coverage.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6234378261 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7097#issuecomment-6234378261). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-17T13:21:11Z. --- Thanks @MarcZX100 for the thorough comparison and review! Hi @inmert — happy to coordinate on this! As Marc noted, #7096 integrates the ASan build and test execution directly into the existing Linux relinker matrix step, avoiding spinning up a separate runner and duplicate build setup while verifying all 31/31 TLS function coverage tests. I have just rebased #7096 cleanly onto latest `origin/main` (`04788b090`). If there are any specific flags, additional test steps, or refinements from your PR you would like to see incorporated, please let me know and I'm very happy to add them to #7096 so we have the best combined coverage.
MarcZX10 commented 2026-10-17 15:29:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T15:29:30Z.


Thanks for coordinating. The current #7096 head now satisfies the issue’s done-when: Debug+ASan selects all 31 TLS coverage tests, passes 31/31 with the fix, and the independent revert control fails specifically in WindowsTlsBuilder::Build with the expected one-byte heap-buffer-overflow. I do not see additional behavior in #7097 that this evidence leaves uncovered; the two PRs target the same workflow coverage.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6235785486 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7097#issuecomment-6235785486). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T15:29:30Z. --- Thanks for coordinating. The current #7096 head now satisfies the issue’s done-when: Debug+ASan selects all 31 TLS coverage tests, passes 31/31 with the fix, and the independent revert control fails specifically in `WindowsTlsBuilder::Build` with the expected one-byte heap-buffer-overflow. I do not see additional behavior in #7097 that this evidence leaves uncovered; the two PRs target the same workflow coverage.
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!7097
No description provided.