test(libSceNKWebKit): let nkwebkit_wtf see null from an impossible allocation under ASan #15003

Merged
xXPBSXx merged 1 commit from upstream-pr/15003 into main 2026-11-03 05:13:06 +00:00
xXPBSXx commented 2026-11-02 09:25:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-11-02T09:25:30Z.


What

The test nkwebkit_wtf was added with #13500 on 2026-10-31 at 11:18 UTC, after that night's nightly run; it failed in the nightly Sanitizers runs of 2026-11-01 and 2026-11-02. It asks WTF::tryFastMalloc for maxSize - 64 bytes and expects nullptr. NKWebKit::PlaceAllocation passes that request on to std::malloc; glibc returns NULL for it, but the ASan allocator aborts instead ("requested allocation size 0xffffffffffffffdf exceeds maximum supported size of 0x10000000000") because allocator_may_return_null defaults to 0.

This PR appends allocator_may_return_null=1 to the test's ASAN_OPTIONS, only for nkwebkit_wtf and only in ASan builds. It uses ENVIRONMENT_MODIFICATION with path_list_append, so the detect_leaks=0 that the nightly sets in sanitizers.yml is kept. Without allocator_may_return_null=1 the nightly options abort the test, because ASan aborts on the deliberately unsatisfiable size before the test can see the null result.

A product ceiling in PlaceAllocation is deliberately not added: it already refuses sizes above SIZE_MAX - slack (#13500), and the test expects exactly the null result the code returns.

Changes one file, core/libs/prx/libSceNKWebKit/CMakeLists.txt (+4).

Tested

  • Ubuntu 24.04, GCC 13.3, ASan + UBSan, RelWithDebInfo, ASAN_OPTIONS=detect_leaks=0 as in the nightly, 08:18 UTC to 08:19 UTC.
  • With the fix: nkwebkit_wtf Passed in 3 of 3 runs.
  • CMakeLists.txt from main, test unchanged (red): Failed in 3 of 3 runs.
  • Fix restored: Passed in 3 of 3 runs. cmake and ninja exited 0 in every arm.
  • python -I tools/check_conventions.py --base 4569fe654a97dbcc07d9e76dd22a6099f3408ab5 passed at 08:21 UTC; git diff --check clean.
  • Not run: Windows and macOS (ASan is Linux only, root CMakeLists.txt:114).

Overlap

Checked against main 4569fe654a with the 1914 open PRs listed at 07:29 UTC. Five PRs change this file (#14949, #14932, #14931, #14172, #13766); git merge-tree of each against this head is clean (08:21 UTC). The block sits inside the test loop after add_test, not after endforeach(), because the latter position conflicted with #14172. #13454 had no fetchable ref; its file list (3 files, read through the API at 08:22 UTC) does not include this file. Rechecked on 2026-11-02 at 09:24 UTC: this head merges with main 88e804b0a7 without a conflict, and none of the 18 pull requests opened since 07:40 UTC (#14980 to #15002) changes this file. Depends on: none.

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

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5117959463 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15003). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-11-02T09:25:30Z. --- ### What The test `nkwebkit_wtf` was added with #13500 on 2026-10-31 at 11:18 UTC, after that night's nightly run; it failed in the nightly Sanitizers runs of 2026-11-01 and 2026-11-02. It asks `WTF::tryFastMalloc` for `maxSize - 64` bytes and expects `nullptr`. `NKWebKit::PlaceAllocation` passes that request on to `std::malloc`; glibc returns NULL for it, but the ASan allocator aborts instead ("requested allocation size 0xffffffffffffffdf exceeds maximum supported size of 0x10000000000") because `allocator_may_return_null` defaults to 0. This PR appends `allocator_may_return_null=1` to the test's `ASAN_OPTIONS`, only for `nkwebkit_wtf` and only in ASan builds. It uses `ENVIRONMENT_MODIFICATION` with `path_list_append`, so the `detect_leaks=0` that the nightly sets in `sanitizers.yml` is kept. Without `allocator_may_return_null=1` the nightly options abort the test, because ASan aborts on the deliberately unsatisfiable size before the test can see the null result. A product ceiling in `PlaceAllocation` is deliberately not added: it already refuses sizes above `SIZE_MAX - slack` (#13500), and the test expects exactly the null result the code returns. Changes one file, `core/libs/prx/libSceNKWebKit/CMakeLists.txt` (+4). ### Tested - Ubuntu 24.04, GCC 13.3, ASan + UBSan, RelWithDebInfo, `ASAN_OPTIONS=detect_leaks=0` as in the nightly, 08:18 UTC to 08:19 UTC. - With the fix: `nkwebkit_wtf` Passed in 3 of 3 runs. - CMakeLists.txt from main, test unchanged (red): Failed in 3 of 3 runs. - Fix restored: Passed in 3 of 3 runs. cmake and ninja exited 0 in every arm. - `python -I tools/check_conventions.py --base 4569fe654a97dbcc07d9e76dd22a6099f3408ab5` passed at 08:21 UTC; `git diff --check` clean. - Not run: Windows and macOS (ASan is Linux only, root `CMakeLists.txt:114`). ### Overlap Checked against main 4569fe654a97dbcc07d9e76dd22a6099f3408ab5 with the 1914 open PRs listed at 07:29 UTC. Five PRs change this file (#14949, #14932, #14931, #14172, #13766); `git merge-tree` of each against this head is clean (08:21 UTC). The block sits inside the test loop after `add_test`, not after `endforeach()`, because the latter position conflicted with #14172. #13454 had no fetchable ref; its file list (3 files, read through the API at 08:22 UTC) does not include this file. Rechecked on 2026-11-02 at 09:24 UTC: this head merges with `main` `88e804b0a7` without a conflict, and none of the 18 pull requests opened since 07:40 UTC (#14980 to #15002) changes this file. Depends on: none. ### 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 AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
BunnyFl commented 2026-11-02 12:01:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T12:01:06Z.

Review: APPROVED


Looks right to me for the sanitizer job. path_list_append on Linux joins with :, which is also ASAN_OPTIONS's separator, so the nightly's detect_leaks=0 survives and allocator_may_return_null=1 is added. With ASAN_OPTIONS unset, the value is just the new flag. Scoping it to nkwebkit_wtf in ASan builds keeps every other test's allocator behaviour strict.

One non-blocking point: on WIN32, the set_tests_properties(... ENVIRONMENT_MODIFICATION "PATH=...") just below replaces the property rather than adding to it, so in an ASan build on Windows the new entry would be dropped. ASan isn't built on Windows today, so nothing breaks. set_property(TEST nkwebkit_${testName} APPEND PROPERTY ENVIRONMENT_MODIFICATION "ASAN_OPTIONS=path_list_append:allocator_may_return_null=1") would make the order irrelevant, though.

I couldn't run it: this machine has no ASan toolchain (Windows/MinGW). This review is from the CMake semantics and your Ubuntu runs and their control.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5736223838 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15003#pullrequestreview-5736223838). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T12:01:06Z. **Review:** APPROVED --- Looks right to me for the sanitizer job. `path_list_append` on Linux joins with `:`, which is also `ASAN_OPTIONS`'s separator, so the nightly's `detect_leaks=0` survives and `allocator_may_return_null=1` is added. With `ASAN_OPTIONS` unset, the value is just the new flag. Scoping it to `nkwebkit_wtf` in ASan builds keeps every other test's allocator behaviour strict. One non-blocking point: on `WIN32`, the `set_tests_properties(... ENVIRONMENT_MODIFICATION "PATH=...")` just below replaces the property rather than adding to it, so in an ASan build on Windows the new entry would be dropped. ASan isn't built on Windows today, so nothing breaks. `set_property(TEST nkwebkit_${testName} APPEND PROPERTY ENVIRONMENT_MODIFICATION "ASAN_OPTIONS=path_list_append:allocator_may_return_null=1")` would make the order irrelevant, though. I couldn't run it: this machine has no ASan toolchain (Windows/MinGW). This review is from the CMake semantics and your Ubuntu runs and their control.
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!15003
No description provided.