Skip to content

test(libharfbuzz): cover guest parent blob lifetime across backend sub-blobs - #23765

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
MarrasFederico:test/harfbuzz-sub-blob-guest-lifetime
Nov 19, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
MarrasFederico:test/harfbuzz-sub-blob-guest-lifetime

Conversation

@MarrasFederico

Copy link
Copy Markdown
Contributor

What

Extend core/libs/tests/GuestHarfBuzzLifecycle.cpp with CheckSubBlobLifetime(const Api& api) to verify parent blob lifetime when backend hb_blob_create_sub_blob holds child slices across named and NID-patched test modes:

  • Creates a guest parent blob via api.blob with HB_MEMORY_MODE_READONLY over an owned byte buffer, local Owner state, and tracked APS5_VABI Destroy callback.
  • Slices two child sub-blobs via hb_blob_create_sub_blob, including a boundary slice whose requested length (10) is clamped by HarfBuzz to 3, verifying expected slice bytes.
  • Releases the caller's parent reference and then each sub-blob sequentially, asserting owner.destroyed == 0 while either sub-blob remains readable and owner.destroyed == 1 only when the last sub-blob is destroyed.

Tested

  • Linux (Linux 7.0.0-43-generic x86_64, g++ 15.2.0):
    • ctest --test-dir build --output-on-failure -V -R '^guest_harfbuzz_lifecycle(_nid)?$' (3/3 runs Passed 2/2, 0.01 sec and 0.00 sec each)
    • ctest --test-dir build --output-on-failure -V -R '^public_headers$' (Passed, 11.86 sec)
    • python3 tools/check_conventions.py --base upstream/main and git diff --check upstream/main passed
    • Temporary negative mutation mapping HB_MEMORY_MODE_READONLY to HB_MEMORY_MODE_DUPLICATE in Lifecycle.cpp with CheckSubBlobLifetime ordered first aborted both unpatched and patched tests deterministically at GuestHarfBuzzLifecycle.cpp:157 (exit 8), then passed after restoring both files
  • Windows (DESKTOP-O0J3UDR, Microsoft Windows NT 10.0.22631.0, MSYS2 g++.exe 16.2.0):
    • ctest --test-dir b --output-on-failure -V -R "^guest_harfbuzz_lifecycle(_nid)?$" (3/3 runs Passed 2/2: 0.59s/0.25s, 0.03s/0.03s, 0.03s/0.04s)

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

@PrivacyOnion PrivacyOnion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_harfbuzz_lifecycle_tests built cleanly.
  • CTest (guest_harfbuzz_lifecycle):
    1/1 Test #5483: guest_harfbuzz_lifecycle .........   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Code reading:
    • Verified core/libs/tests/GuestHarfBuzzLifecycle.cpp:CheckSubBlobLifetime correctly creates parent blob with HB_MEMORY_MODE_READONLY and verifies parent data with CheckData
    • Verified hb_blob_create_sub_blob offsets (1, 4) and (5, 10) are valid, with HarfBuzz clamping the second sub-blob from length 10 to 3 matching remaining buffer size (8 - 5 = 3)
    • Verified sequential hb_blob_destroy calls on parent, first, and second sub-blobs assert owner.destroyed remains 0 until the final sub-blob is destroyed (owner.destroyed == 1)
    • Verified no comments in modified code, adhering strictly to AGENTS.md rules
    • Verified test integration into main() runner across both unpatched and NID-patched modes

Looks Good To Me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants