test(libSceNKWebKit): keep clang from binding the AffineTransform constructor export to the implicit one #22859

Merged
Jazeupoi merged 1 commit from upstream-pr/22859 into main 2026-11-18 13:33:41 +00:00
Jazeupoi commented 2026-11-18 12:59:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-18T12:59:06Z.


What

nkwebkit_affinetransformguestpointers crashes on macOS (SegFault) without ever calling the library.

WebCore::AffineTransform target; default-initializes the struct, so clang emits its implicit default constructor in the test. The Itanium name of that constructor is _ZN7WebCore15AffineTransformC1Ev, the same symbol as the extern "C" export the test checks. Clang then binds the test's calls to _ZN7WebCore15AffineTransformC1Ev(unreadable) to its own inline constructor: the optimized main stores the identity matrix straight to address 0x10 and faults, instead of calling the export, which would throw not implemented.

target{} value-initializes the aggregate through its member initializers, so the constructor is no longer emitted and the calls go to libSceNKWebKit.prx. The test checks the same things as before.

Linux and Windows build with GCC and are not affected.

Tested

macOS 27.0.1, Apple clang 21.0.0, x86_64 build on an M4 Mac (Rosetta):

  • main: nkwebkit_affinetransformguestpointers fails with SegFault (EXC_BAD_ACCESS at 0x30 in main). The -O0 IR of the test has a linkonce_odr definition of _ZN7WebCore15AffineTransformC1Ev, and the -O3 IR replaces the call with a 48-byte memcpy to inttoptr (i64 16 to ptr).
  • This PR: the three nkwebkit_affinetransform* tests pass, 3 runs each (ctest --repeat until-fail:3).

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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 (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5376407987 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22859). Originally posted by [Jazeupoi](https://github.com/Jazeupoi) on 2026-11-18T12:59:06Z. --- ### What `nkwebkit_affinetransformguestpointers` crashes on macOS (SegFault) without ever calling the library. `WebCore::AffineTransform target;` default-initializes the struct, so clang emits its implicit default constructor in the test. The Itanium name of that constructor is `_ZN7WebCore15AffineTransformC1Ev`, the same symbol as the `extern "C"` export the test checks. Clang then binds the test's calls to `_ZN7WebCore15AffineTransformC1Ev(unreadable)` to its own inline constructor: the optimized `main` stores the identity matrix straight to address `0x10` and faults, instead of calling the export, which would throw `not implemented`. `target{}` value-initializes the aggregate through its member initializers, so the constructor is no longer emitted and the calls go to `libSceNKWebKit.prx`. The test checks the same things as before. Linux and Windows build with GCC and are not affected. ### Tested macOS 27.0.1, Apple clang 21.0.0, x86_64 build on an M4 Mac (Rosetta): - `main`: `nkwebkit_affinetransformguestpointers` fails with SegFault (`EXC_BAD_ACCESS` at `0x30` in `main`). The `-O0` IR of the test has a `linkonce_odr` definition of `_ZN7WebCore15AffineTransformC1Ev`, and the `-O3` IR replaces the call with a 48-byte `memcpy` to `inttoptr (i64 16 to ptr)`. - This PR: the three `nkwebkit_affinetransform*` tests pass, 3 runs each (`ctest --repeat until-fail:3`). ### 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) and the licence notice of code adapted from upstream (see AGENTS.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 (Claude Code)
PrivacyOnion commented 2026-11-18 13:01:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-18T13:01:01Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against e490141ae6:

  • Conventions: tools/check_conventions.py passed.
  • Build: nkwebkit_affinetransformguestpointers_tests built cleanly.
  • CTest (nkwebkit_affinetransformguestpointers):
    1/1 Test #4485: nkwebkit_affinetransformguestpointers ...   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Code reading:
    • Verified AffineTransformGuestPointers.cpp:81 initialization change from default-initialization WebCore::AffineTransform target; to value-initialization WebCore::AffineTransform target{}; to prevent clang emission of implicit default constructor colliding with library export symbol
    • Verified subsequent initialization call _ZN7WebCore15AffineTransformC1Edddddd(&target, 2, 0, 0, 2, 10, 20) fully populates target before use
    • Verified compliance with AGENTS.md rules (no comments added, conventions pass, no extra files or invalid stubs)
    • Confirmed that the test logic exercises the blend function without memory safety issues or undefined behavior

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5957037663 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22859#pullrequestreview-5957037663). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-18T13:01:01Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `e490141ae6`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `nkwebkit_affinetransformguestpointers_tests` built cleanly. - **CTest** (`nkwebkit_affinetransformguestpointers`): ``` 1/1 Test #4485: nkwebkit_affinetransformguestpointers ... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Code reading**: - Verified AffineTransformGuestPointers.cpp:81 initialization change from default-initialization WebCore::AffineTransform target; to value-initialization WebCore::AffineTransform target{}; to prevent clang emission of implicit default constructor colliding with library export symbol - Verified subsequent initialization call _ZN7WebCore15AffineTransformC1Edddddd(&target, 2, 0, 0, 2, 10, 20) fully populates target before use - Verified compliance with AGENTS.md rules (no comments added, conventions pass, no extra files or invalid stubs) - Confirmed that the test logic exercises the blend function without memory safety issues or undefined behavior Looks Good To Me
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!22859
No description provided.