mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 22:11:04 +01:00
fix/repacker-split-storage-6659
22558
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
5b1aa7c9db |
[repacker] Bound clone buffers by each ligature split range
Many short ranges allocated the original LigatureSet offset array for every clone, retaining quadratic buffer space even after shrink_buffer moved the tails. Bound capacity by the number of offset slots in the range, since each emitted set consumes at least one slot. Advance through earlier ligature counts once across ordered ranges and stop scanning at each range's end. Add a compact graph requiring one subtable per coverage entry and verify counts, glyphs and connectivity. An 8000-range run reduces peak RSS from 163 MB to 32 MB. Source-link movement and coverage filtering still take quadratic time across many ranges; document that remaining work rather than claiming a full fix. Testing: full suite (303 passed, 1 skipped), ASan/UBSan repacker tests, HB_NO_BEYOND_64K repacker tests, and 520 injected allocation failures in a temporary harness. The combined fix series also passed 228650 ASan fuzzer runs with failing malloc. Assisted-by: OpenAI Codex |
||
|
|
95b711ccb8 |
[repacker] Cache LigatureSet ids throughout subtable splitting
Refresh the id map once after unsharing and keep it in the split context. Reuse it in every clone_range and in shrink, where repeated index_for_offset scans previously made a large retained run quadratic. Pass ligature counts by reference instead of copying them per range. Exercise the 4000-set shared run both before and after a large ligature to cover retained and moved runs, checking distinct ids in each case. Testing: meson test -C build (303 passed, 1 skipped). Assisted-by: OpenAI Codex |
||
|
|
f6b7a4cb72 | [NEWS] Fixup | ||
|
|
b17af8a343 |
[repacker] Un-share LigatureSets before splitting, in bounded time and memory (#6659)
* [repacker] Un-share LigatureSets before splitting, in bounded time and memory When the subset serializer deduplicates a LigatureSet that is reachable from several coverage entries of one LigatureSubst, pop_pack() links all of those entries to a single LigatureSet vertex. The LigatureSubst splitter numbers ligatures per coverage entry and then edits the LigatureSet vertices in place (move_children, compact_liga_set, shrink), which assumes one vertex per entry, so the shared entries silently lose their ligatures. #6088 removed the duplicate_shared_liga_sets pre-pass that used to guard this, on the assumption that as_mutable_table()'s copy-before-mutate made it redundant; but that only un-shares a child shared with *other* parents, not one reached by several links from the same parent, so the bug came back. Restore the pre-pass, but make it linear in both time and memory, since a naive restore is O(n^2) on a subtable whose n coverage entries all share one set: - Memory: LigatureSet::subset()/Ligature::subset() each add one virtual link to Coverage ("ensure Coverage is packed after this") per subset call, and pop_pack()'s merge_virtual_links appends them to the deduped vertex without collapsing, so the shared set accumulates n redundant virtual links. duplicate(copy_table) copies that whole vector into every per-entry clone, i.e. O(n^2). unshare_duplicate_children() collapses each set's duplicate virtual links to one (dedup_virtual_links, fixing the dropped links' incoming-edge counts) before cloning, so each clone copies O(1), and does the whole un-share in a single pass over the parent's links instead of an O(n) remap-and-rescan per entry. - Time: the split's analysis passes (compute_split_points, total_number_ligas, liga_counts) and clone_range() each did an O(n) index_for_offset() per entry. Precompute the ligatureSet index -> object id map once per split and pass it to the analysis passes, and in clone_range() move each run of fully-contained sets with a single move_children() (and look moved sets up through the new, small subtable) instead of a move_child()/as_mutable_table() per entry. The un-share runs after the analysis passes: the deep copies share the same Ligatures and keep the same ligature.len, so the counts and split points are unchanged. Testing: the K86 correctness reproducer now loses 0 of 8400 ligatures (was lossy). The 1P5QWD69 reproducer (32759 entries sharing one set, 4 split subtables) drops from ~24 s / an OOM at ~12 GB to ~0.65 s CPU and ~137 MB peak RSS; instruction count vs entry count is linear (doubling n multiplies work by ~1.8x, not ~4x), and peak RSS is O(n). Adds test_resolve_with_liga_split_shared_liga_set to test-repacker. The full meson test suite (including the subset and subset+repack suites) passes. Discovered by Anthropic's OSS Scanner, as vulnerabilities ANT-2026-K86LK9JR (dropped ligatures) and ANT-2026-1P5QWD69 (quadratic DoS). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [repacker] Cache LigatureSet ids while cloning split ranges Moving a run of LigatureSets still looked each set up by scanning the new subtable's links. This left clone_range quadratic in the run length. Resolve the original offsets once before moving sets, and reuse their object ids. Extract the existing copy-before-mutate check so cached ids retain the same handling of children shared with other parents. Add a 4000-set moved-run test checking alternating shared ligatures. Instrumented lookup comparisons for runs of 1000/2000/4000 sets drop from 501505/2003005/8006005 to 5/5/5. Testing: full build and meson test -C build (281/281 passed). Assisted-by: OpenAI Codex --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
e563058688 |
[font] Add hb_font_create_without_funcs_or_fail() (#6651)
Let clients install their own font funcs without initializing and immediately discarding the default backend. Return NULL if the font object or its initial variation coordinates cannot be allocated. Keep hb_font_create()'s initialization order and behavior. Use the new constructor in hb-ft, Fontconfig, explicit tool backend selection, and the font benchmarks. This avoids loading a second FT_Face when FreeType is the default while preserving the caller's face. Document the custom-client use case and add API and stream-read regressions. Testing: full Meson suite (302 passed, one skipped), generated docs, reduced-feature builds, allocator failures, and tool/benchmark checks. Supersedes: https://github.com/harfbuzz/harfbuzz/pull/6648 Assisted-by: OpenAI Codex Co-authored-by: Mattias Eriksson <me@axentia.se> |
||
|
|
438c3a8b11 |
[repacker] Cache LigatureSet ids while cloning split ranges
Moving a run of LigatureSets still looked each set up by scanning the new subtable's links. This left clone_range quadratic in the run length. Resolve the original offsets once before moving sets, and reuse their object ids. Extract the existing copy-before-mutate check so cached ids retain the same handling of children shared with other parents. Add a 4000-set moved-run test checking alternating shared ligatures. Instrumented lookup comparisons for runs of 1000/2000/4000 sets drop from 501505/2003005/8006005 to 5/5/5. Testing: full build and meson test -C build (281/281 passed). Assisted-by: OpenAI Codex |
||
|
|
136b04439b |
Merge pull request #6656 from harfbuzz/fix/raster-bgra-endianness-6655
[raster] Preserve BGRA byte order on big-endian systems |
||
|
|
73a5bc580a |
[repacker] Un-share LigatureSets before splitting, in bounded time and memory
When the subset serializer deduplicates a LigatureSet that is reachable from several coverage entries of one LigatureSubst, pop_pack() links all of those entries to a single LigatureSet vertex. The LigatureSubst splitter numbers ligatures per coverage entry and then edits the LigatureSet vertices in place (move_children, compact_liga_set, shrink), which assumes one vertex per entry, so the shared entries silently lose their ligatures. #6088 removed the duplicate_shared_liga_sets pre-pass that used to guard this, on the assumption that as_mutable_table()'s copy-before-mutate made it redundant; but that only un-shares a child shared with *other* parents, not one reached by several links from the same parent, so the bug came back. Restore the pre-pass, but make it linear in both time and memory, since a naive restore is O(n^2) on a subtable whose n coverage entries all share one set: - Memory: LigatureSet::subset()/Ligature::subset() each add one virtual link to Coverage ("ensure Coverage is packed after this") per subset call, and pop_pack()'s merge_virtual_links appends them to the deduped vertex without collapsing, so the shared set accumulates n redundant virtual links. duplicate(copy_table) copies that whole vector into every per-entry clone, i.e. O(n^2). unshare_duplicate_children() collapses each set's duplicate virtual links to one (dedup_virtual_links, fixing the dropped links' incoming-edge counts) before cloning, so each clone copies O(1), and does the whole un-share in a single pass over the parent's links instead of an O(n) remap-and-rescan per entry. - Time: the split's analysis passes (compute_split_points, total_number_ligas, liga_counts) and clone_range() each did an O(n) index_for_offset() per entry. Precompute the ligatureSet index -> object id map once per split and pass it to the analysis passes, and in clone_range() move each run of fully-contained sets with a single move_children() (and look moved sets up through the new, small subtable) instead of a move_child()/as_mutable_table() per entry. The un-share runs after the analysis passes: the deep copies share the same Ligatures and keep the same ligature.len, so the counts and split points are unchanged. Testing: the K86 correctness reproducer now loses 0 of 8400 ligatures (was lossy). The 1P5QWD69 reproducer (32759 entries sharing one set, 4 split subtables) drops from ~24 s / an OOM at ~12 GB to ~0.65 s CPU and ~137 MB peak RSS; instruction count vs entry count is linear (doubling n multiplies work by ~1.8x, not ~4x), and peak RSS is O(n). Adds test_resolve_with_liga_split_shared_liga_set to test-repacker. The full meson test suite (including the subset and subset+repack suites) passes. Discovered by Anthropic's OSS Scanner, as vulnerabilities ANT-2026-K86LK9JR (dropped ligatures) and ANT-2026-1P5QWD69 (quadratic DoS). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
9e813f3f7b |
[ci] Prototype faster Windows builds and compiler caching (#6652)
* [ci] Let Meson choose Windows cross-build parallelism Remove the three-job limit left over from CircleCI. The Windows cross build now runs on GitHub Actions and can use Meson's default parallelism. Validation: bash -n .ci/build-win.sh; meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex * [ci] Skip Pixman tests and demos in Windows bundles The cross-build only runs HarfBuzz's test suite, but Pixman still builds its own tests and demos by default. Disable both, including their shared test utilities, while retaining the libraries used by Cairo. Validation: Pixman 0.43.4 Meson setup and target introspection; bash -n .ci/build-win.sh; meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex * [ci] Route MinGW cross-compilation through ccache Meson does not automatically prepend ccache to compilers selected in a cross file. Generate a CI-only overlay with explicit compiler wrappers and isolate the cache by target architecture. Keep the regular cross files usable without ccache installed. Validation: actionlint; C/C++ Meson cross-builds for i686 and x86_64, including cache hits on rebuild; meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex * [ci] Trim MSVC fallback dependencies Disable Cairo and dependency tests for GLib and libffi. Keep GLib so HarfBuzz's API tests, including DirectWrite, still build and run under MSVC. MSYS2 continues to cover the Cairo integration on Windows. Validation: actionlint; meson test -C build (302 passed, one skipped). Native MSVC validation remains in CI. Assisted-by: OpenAI Codex * [ci] Cache MSYS2 compiler outputs by toolchain Install the native ccache package for each MSYSTEM and persist its workspace cache separately for MINGW64 and CLANG64. Check compiler contents across package updates and report compiler-cache statistics. Validation: actionlint; YAML assertions; meson test -C build (302 passed, one skipped). Native MSYS2 validation remains in CI. Assisted-by: OpenAI Codex * [ci] Use ccache with explicitly selected Clang compilers Setting CC and CXX prevents Meson from automatically enabling ccache. Wrap both compilers explicitly and isolate each sanitizer's cache. Validation: actionlint; standalone Meson ASan/UBSan C/C++ build and cache hits on rebuild; meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex * [ci] Separate compiler caches by workflow Linux and Rust shared a cache key, while Valgrind used the unscoped default. Include the workflow name in cache keys consistently and give Linux and Rust 1G each, since their 500MB caches were full in PR #6637. Validation: actionlint; meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex * [ci] Cancel superseded pull-request workflow runs Group pull-request runs by workflow and PR number so new commits cancel older queued or running checks. Give non-PR runs unique groups, leaving main-branch builds and tag releases independent. Validation: actionlint; workflow concurrency assertions; meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex * [ci] Reduce CIFuzz runs to five minutes Set fuzz-seconds to 300 instead of 600 to shorten pull-request feedback. Validation: actionlint and git diff --check. Tests were not rerun for this CI-only duration change. Assisted-by: OpenAI Codex * [ci] Skip documentation and introspection in the Rust job Disable documentation setup and GIR/typelib generation, and remove their build dependencies. The docs job covers these outputs. Retain the full Rust integration test suite, Clippy, and rustfmt. Validation: actionlint, git diff --check, and meson test -C build. Assisted-by: OpenAI Codex * [ci] Cache Cargo dependencies and Rust build artifacts Cache downloaded Cargo sources and Meson's Rust debugoptimized target outputs, including the rebuilt standard library. Scope the cache to the compiler version and build configuration, and save updated entries for subsequent runs without caching generated bindings or Meson state. Retain the Cargo invocation so it checks source freshness after restore. Validation: actionlint, git diff --check, and meson test -C build. Remote cache restoration remains to be exercised in Actions. Assisted-by: OpenAI Codex * [ci] Drop unused Graphite dependency from Valgrind The Valgrind job leaves Graphite support disabled, so its development package is unused. Remove it without changing the build or test options. Validation: actionlint and git diff --check. Tests were not rerun for this CI-only package-list change. Assisted-by: OpenAI Codex * [ci] Cache amalgamated configuration builds Use ccache for each configuration's core and subset compilation. Split core compilation from linking so ccache can store its object while retaining the existing link check and accumulated failure status. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). The HB_TINY core/subset commands compile and link successfully and produce cache hits on a repeat build. Assisted-by: OpenAI Codex * [ci] Disable the ICU fallback in MSVC builds The forcefallback wrap mode also builds ICU for its default auto feature. Disable it explicitly to avoid building the large optional dependency. Keep GLib and the native Windows backends so API and DirectWrite tests remain enabled. Linux and MSYS2 retain ICU integration coverage. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). Native MSVC validation remains in CI. Assisted-by: OpenAI Codex * [ci] Build configuration checks two at a time Run two configurations concurrently within the existing runner. Use separate outputs and logs per configuration, then print grouped logs and collect failures after waiting for each pair. Retain all six core link checks and subset compilations without adding matrix jobs. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). All six configurations compile and link with the real compiler. A stub-compiler check confirms the two-worker limit and failure propagation. Assisted-by: OpenAI Codex * [ci] Cache installed MSVC dependencies separately Build GLib, FreeType, PNG, and zlib in a small Meson dependency project and cache the installed prefix. Key it by architecture, compiler, SDK, Python version, wrap definitions, and CI build configuration. Use pkg-config and nofallback for HarfBuzz so cached dependencies avoid repeated fallback configuration and linking. Keep generated Meson state out of the cache and retain GLib API and native Windows backend tests. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). Pinned fallback dependencies built and installed on Linux. A relocated-prefix nofallback consumer compiled, linked, and passed its runtime smoke test. Native Windows behavior remains for CI. Assisted-by: OpenAI Codex * [ci] Try size optimization in the x86 MSVC job Use Meson optimization=1 (/O1) for x86 while retaining optimization=3 (/O2 /Gw) for amd64. Keep the two existing jobs and their tests, and set b_ndebug=true explicitly to preserve the previous release assertion setting when the x86 build type becomes custom. This is a CI compile-time experiment; dependency-prefix builds remain release builds and the amd64 job retains optimized MSVC coverage. Validation: actionlint, option/matrix checks, and meson test -C build (302 passed, one skipped). Native compiler timing remains for CI. Assisted-by: OpenAI Codex * [ci] Stop forcing a Ragel build in the Linux job Use the checked-in generated headers when Ragel is unavailable instead of building the generator subproject for every clean CI checkout. Leave normal system-Ragel discovery and developer regeneration intact. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). The latest runner log confirms no system Ragel is installed. Assisted-by: OpenAI Codex * [ci] Use compiler dependencies for configs cache entries ccache 4.9 treats Ragel line-marker filenames as inputs and fails to stat paths such as hb-ot-shaper-indic-machine.rl and the pseudo-file NONE when compiling the amalgamations. Compilation succeeds through fallback, but every cache request fails with bad_input_file. Enable depend mode and emit full compiler dependencies with -MD, avoiding those preprocessor line-marker paths. Validation: ccache 4.9.1 with GCC 13.5 builds all six configurations; the repeat build has 12 direct hits and zero errors. All executables run, and concurrency/failure checks pass. Actionlint, diff checks, and meson test -C build pass (302 passed, one skipped). Assisted-by: OpenAI Codex * [ci] Reuse unchanged Cargo cache snapshots Key Cargo snapshots by compiler, build configuration, Rust sources, and public headers instead of run ID. An exact cache hit can now skip the upload rather than storing another copy on each successful run. Retain the existing restore prefix for incremental rebuilds. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). Remote snapshot reuse remains for CI. Assisted-by: OpenAI Codex * [ci] Avoid saving unchanged compiler-cache snapshots Restore compiler caches through a shared setup action and save them explicitly only when compilation reports cache misses. Keep existing restore prefixes and make cache-save failures nonfatal. Before saving ccache, prune entries that were not used during the job. This avoids duplicate snapshots on fully cached runs and removes unrelated restored objects from changed snapshots. Key the MSVC installed prefix by its dependency build inputs rather than unrelated workflow edits; dependency options remain in the hashed helper project. Validation: actual ccache 4.9.1 cold/warm and pruning checks; sccache statistics and failure-path checks; nine workflow setup/save pairs; actionlint, git diff --check, and meson test -C build (302 passed, one skipped). Remote uploads remain for CI. Assisted-by: OpenAI Codex * [ci] Restore Ragel subproject coverage on Linux Reinstate ragel_subproject=true so CI continues exercising the bundled Ragel build and generated-source regeneration. This was the only CI job covering that path, as noted in the PR discussion. Keep the configs depend-mode fix, which handles Ragel line-marker pseudo-files independently of whether the generator is rebuilt. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex |
||
|
|
10b3ba833b |
[meson] Fix C++14 selection with clang-cl (#6658)
clang-cl 23.1.5 ignores /std:c++14, leaving Meson's /clang:-std=c++11 in effect and causing C++14 errors in MSVC STL. Forward -std=c++14 through the Clang driver instead. Verified with a 32-bit clang-cl 23.1.5 build and all 63 available Meson tests on Windows. Assisted-by: Kimi Code |
||
|
|
3958001baa |
[ci] Restore Ragel subproject coverage on Linux
Reinstate ragel_subproject=true so CI continues exercising the bundled Ragel build and generated-source regeneration. This was the only CI job covering that path, as noted in the PR discussion. Keep the configs depend-mode fix, which handles Ragel line-marker pseudo-files independently of whether the generator is rebuilt. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex |
||
|
|
f87e9d774c |
[gvar] Charge tuple region eval and point-number decoding to work budget (#6654)
apply_deltas_to_points() only charged the glyph work budget (HB_BUDGET_GLYPH) for tuple variations that actually applied, and only by the glyph's point count, after calculate_scalar() had already walked gvar.axisCount axes for every tuple header. A ~35 KB font with axisCount 8192 and 4095 non-applying tuples on a composite-multiplied glyph could hold one hb_font_get_glyph_extents() call for over a minute while using ~3% of the budget. Two further pieces of work were also uncharged: the shared point-number list is decoded on every glyph load, and an applied tuple decodes/applies indices.length deltas, which can exceed the point count charged. Following the project's "charge before doing the work" idiom (#6256, #6410), charge 1 + axisCount per tuple before its region is evaluated (bounding calculate_scalar() regardless of the scalar cache or outcome), shared_indices.length once per load after the shared point numbers are decoded, and indices.length per applied tuple before its deltas are decoded. A font whose tuple work exceeds the budget now fails the glyph load (outline/extents return false) instead of finishing slowly; real fonts (a dozen axes, tens of tuples) pay a few hundred units per load. Adds test_hb_draw_gvar_budget to test/api/test-draw.c covering both the unapplied-tuple region charge and the point-number charges. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-S2OJWJHX. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
388d91d96e |
[instancer] Dedup VarStore delta rows by sorting, not by a row hash (#6653)
item_variations_t::as_item_varstore() and compile_varidx_map() removed duplicate ItemVariationStore delta rows and mapped them to new VariationIndex values with an hb_hashmap_t keyed by pointer-to-row, which hashes and compares the row contents. hb_array_t::hash() is an invertible FNV-1a over whole 32-bit words with a fixed seed, so a font author can solve the last delta of each row to force thousands of distinct rows to share one 30-bit hash. Keys with equal hashes probe the same slots at every table size, so every insert and lookup walks all earlier rows and the dedup goes quadratic: a 320 KB font cost about 30 s of CPU in hb-subset --variations where an ordinary font of the same size took 0.02 s. Replace both content-keyed maps with a sort-based dedup that does not depend on the row hash: - as_item_varstore() collects the candidate rows in major/minor order, then sorts an index of them by row content (ties broken by position) and flags each row equal to its predecessor, keeping the first occurrence. Encodings are then rebuilt per major in the original order. - compile_varidx_map() collects (row, new VarIdx) pairs while splitting encodings, sorts them by content, and matches each front-mapping row by binary search instead of probing the map. Both are O(n log n) for any font and keep the output deterministic. Rows reaching this code are already globally de-duplicated by content, so the matches are unique. Output is byte-identical: the subset suite's partial-instance tests pass unchanged, and instancing RobotoFlex, MPLUS1 and AdobeVFPrototype (CFF2) is byte-identical to before. The colliding reproducer now instances in well under a second. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-PT58IWSN. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
0264035291 |
[subset] Seed the serializer object-dedup hash per serialization (#6657)
pop_pack() deduplicates packed objects through packed_map, an open-addressing hashmap keyed by object content. object_t::hash() used fasthash32 with a fixed seed, which is invertible, so a font could craft thousands of distinct objects -- e.g. 16-byte GPOS PairSets -- that all share one 30-bit hash. Every insert and lookup then walks the whole collision chain and the dedup goes quadratic: a 337 KB crafted font took 56 s of CPU in hb-subset where an ordinary font the same size took 0.2 s. Seed the hash with a value computed once per hb_serialize_context_t from two ASLR-randomized addresses (the context's own and a stack frame). A font being subset cannot observe them, so it cannot precompute colliding objects. With ASLR disabled the seed folds to a constant, i.e. no worse than the previous fixed seed. The seed never changes output: packed_map is lookup-only and dedup keeps the first-inserted object, independent of hash order. The per-object hash is cached on object_t so the map's del(), which hashes the key itself, sees the same seeded value without touching hb-map.hh. Testing: full meson test passes (281/281). Subset output is byte-identical to before and identical across two different seeds, verified on NotoNastaliqUrdu, Amiri, AwamiNastaliq, NotoSansDevanagari, Roboto, NotoSansCJKsc, PingFang and NotoColorEmoji. Instructions retired are unchanged (<0.01%) on a same-build-dir A/B. The crafted reproducer drops from 56 s to 0.13 s. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-3T4G5NLB. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
4fd912a3c8 |
[ci] Avoid saving unchanged compiler-cache snapshots
Restore compiler caches through a shared setup action and save them explicitly only when compilation reports cache misses. Keep existing restore prefixes and make cache-save failures nonfatal. Before saving ccache, prune entries that were not used during the job. This avoids duplicate snapshots on fully cached runs and removes unrelated restored objects from changed snapshots. Key the MSVC installed prefix by its dependency build inputs rather than unrelated workflow edits; dependency options remain in the hashed helper project. Validation: actual ccache 4.9.1 cold/warm and pruning checks; sccache statistics and failure-path checks; nine workflow setup/save pairs; actionlint, git diff --check, and meson test -C build (302 passed, one skipped). Remote uploads remain for CI. Assisted-by: OpenAI Codex |
||
|
|
d6d0d34bba |
[ci] Reuse unchanged Cargo cache snapshots
Key Cargo snapshots by compiler, build configuration, Rust sources, and public headers instead of run ID. An exact cache hit can now skip the upload rather than storing another copy on each successful run. Retain the existing restore prefix for incremental rebuilds. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). Remote snapshot reuse remains for CI. Assisted-by: OpenAI Codex |
||
|
|
5ae8b24811 |
[ci] Use compiler dependencies for configs cache entries
ccache 4.9 treats Ragel line-marker filenames as inputs and fails to stat paths such as hb-ot-shaper-indic-machine.rl and the pseudo-file NONE when compiling the amalgamations. Compilation succeeds through fallback, but every cache request fails with bad_input_file. Enable depend mode and emit full compiler dependencies with -MD, avoiding those preprocessor line-marker paths. Validation: ccache 4.9.1 with GCC 13.5 builds all six configurations; the repeat build has 12 direct hits and zero errors. All executables run, and concurrency/failure checks pass. Actionlint, diff checks, and meson test -C build pass (302 passed, one skipped). Assisted-by: OpenAI Codex |
||
|
|
8988ff42a0 |
[ci] Stop forcing a Ragel build in the Linux job
Use the checked-in generated headers when Ragel is unavailable instead of building the generator subproject for every clean CI checkout. Leave normal system-Ragel discovery and developer regeneration intact. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). The latest runner log confirms no system Ragel is installed. Assisted-by: OpenAI Codex |
||
|
|
aa7a824cc4 |
[JSTF] Expose extender glyphs via hb_ot_layout_get_extender_glyphs (#6568)
* [JSTF] Expose extender glyphs via hb_ot_layout_get_extender_glyphs The JSTF table is already parsed but never exposed to clients. Extender glyphs are the most widely populated part of it and are useful for cursive-script justification implementations that want to prefer a font-provided extender over the plain U+0640 TATWEEL fallback. Adds hb_ot_layout_get_extender_glyphs(face, script, language, start_offset, &count, glyphs) following the standard iterator idiom used by hb_ot_layout_get_attach_points and friends: NULL for size probing, inout count for pagination. Only the script tag is consulted: per the OT spec, extender glyphs live directly on JstfScript and do not vary by language. JstfLangSys carries per-language justification priorities, but exposing those is both harder and less common among fonts than the (already rare) JSTF table itself; that can be a separate accessor later. Co-authored-by: Helmut Januschka <helmut@januschka.com> * [JSTF] Minor simplification by refactoring exposed methods --------- Co-authored-by: Helmut Januschka <helmut@januschka.com> Co-authored-by: Behdad Esfahbod <behdad@behdad.org> |
||
|
|
95df2ee9f3 |
[ci] Try size optimization in the x86 MSVC job
Use Meson optimization=1 (/O1) for x86 while retaining optimization=3 (/O2 /Gw) for amd64. Keep the two existing jobs and their tests, and set b_ndebug=true explicitly to preserve the previous release assertion setting when the x86 build type becomes custom. This is a CI compile-time experiment; dependency-prefix builds remain release builds and the amd64 job retains optimized MSVC coverage. Validation: actionlint, option/matrix checks, and meson test -C build (302 passed, one skipped). Native compiler timing remains for CI. Assisted-by: OpenAI Codex |
||
|
|
00bd61d584 |
[ci] Cache installed MSVC dependencies separately
Build GLib, FreeType, PNG, and zlib in a small Meson dependency project and cache the installed prefix. Key it by architecture, compiler, SDK, Python version, wrap definitions, and CI build configuration. Use pkg-config and nofallback for HarfBuzz so cached dependencies avoid repeated fallback configuration and linking. Keep generated Meson state out of the cache and retain GLib API and native Windows backend tests. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). Pinned fallback dependencies built and installed on Linux. A relocated-prefix nofallback consumer compiled, linked, and passed its runtime smoke test. Native Windows behavior remains for CI. Assisted-by: OpenAI Codex |
||
|
|
7a2081ac43 |
[ci] Build configuration checks two at a time
Run two configurations concurrently within the existing runner. Use separate outputs and logs per configuration, then print grouped logs and collect failures after waiting for each pair. Retain all six core link checks and subset compilations without adding matrix jobs. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). All six configurations compile and link with the real compiler. A stub-compiler check confirms the two-worker limit and failure propagation. Assisted-by: OpenAI Codex |
||
|
|
5410a1adf4 |
[ci] Disable the ICU fallback in MSVC builds
The forcefallback wrap mode also builds ICU for its default auto feature. Disable it explicitly to avoid building the large optional dependency. Keep GLib and the native Windows backends so API and DirectWrite tests remain enabled. Linux and MSYS2 retain ICU integration coverage. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). Native MSVC validation remains in CI. Assisted-by: OpenAI Codex |
||
|
|
5ee557a991 |
[subset] Bound avar2 offset-compensation (binary search instead of quadratic) (#6642)
* [subset] Bound avar2 offset-compensation's quadratic breakpoint work avar::_subset_avar2() builds the offset-compensation knots and runs _avar2_estimate_offset_error() twice per narrowed axis; every breakpoint and every estimator sample is looked up in the old segment map, the instantiated mapping and the knots by linear search, so the cost is quadratic in the axis's avar breakpoints and nothing bounded it (42 s of CPU for a 131 KB font, re-run on each serializer out-of-room retry). Add HB_BUDGET_SUBSET_TABLE to hb-limits.hh (same hb_budget_spend() idiom as the rendering budgets) and, right before the knot loop and the estimator, charge (256 + breakpoints) * 8 * breakpoints from a budget shared by all axes of the table. Charging at the point where the quadratic work starts covers the O(n^2) knot-collection loop and its map_float() calls too. On exhaustion the table fails through c->serializer->check_success(), so the whole subset fails (hb_subset_or_fail() returns NULL) rather than avar being silently dropped from an avar2-instanced font. The budget is 1<<30: a 5,000-breakpoint axis narrowed to -900:900 is still admitted (0.6 s), while 16,385 and 32,769 breakpoints are rejected in 0.01 s (the 42 s DoS). A reviewer may tighten it; real avar maps have a handful of breakpoints, far below the cap. Adds test_avar2_restrict_many_breakpoints to test/api/test-subset-avar2.c. This caps the cost; it does not remove the quadratic algorithm. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-CWJXX1BL. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [subset] Bound avar2 offset-compensation tuple memory to the table size avar::_subset_avar2() adds one item_variations_t tuple per retained avar v1 breakpoint and per biased axis, and add_tuple() stores each as a dense column with one bool and one float per row of the VarData it joins. VarData.itemCount can be 65535 with zero-width rows (a 6-byte VarData with no regions passes sanitize), so breakpoints x rows x 5 bytes is not bounded by the font: a 20 KB font drove hb-subset to 2.8 GB, and add_tuple() silently dropped the failed allocation so the result still exited 0. Charge each tuple's item_count deltas to a budget before the add_tuple() call, at all three avar2 sites (empty-region bias, knot tents, free-axis bias), with the existing hb_budget_spend() idiom. The budget is max(HB_AVAR2_MAX_DELTAS_MIN, HB_AVAR2_MAX_DELTAS_FACTOR x table length) -- 128 deltas per byte, floor 65536, new macros in hb-limits.hh next to the other table-derived limits. Exhaustion fails the subset through c->serializer->check_success(false) rather than dropping avar. The attack font is now rejected with a 19 MB peak instead of 2.8 GB; valid fonts (a few deltas per byte) stay far below the budget. Adds test_avar2_empty_rows to test/api/test-subset-avar2.c: 513 breakpoints (which clear the quadratic estimate budget) with a 65535-row region-less VarData, so the delta budget is what rejects it. The charge is placed in the caller; the sibling improvement of making add_tuple() return failure instead of swallowing the dropped allocation lives in hb-ot-var-common.hh and is left for that file's own change. The as_item_varstore() rows x regions allocation and duplicate_row() remain uncovered, as in the report. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-3HO8JDDV. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [subset] Binary-search avar2 offset compensation instead of budgeting it Offset compensation looked every breakpoint and estimator sample up in the old segment map, the instantiated mapping and the knots by linear search, and inserted each breakpoint knot by shifting, so its cost was quadratic in the axis's breakpoints. The previous commit capped that with HB_BUDGET_SUBSET_TABLE; remove the quadratic work instead: - SegmentMaps::map_float() takes a sorted flag; for maps whose fromCoords ascend it finds the exact-match run and the segment by binary search, which lands where the linear scans do. - The instantiated mapping is sorted by fromCoord, and the knots by z, so _avar2_map_new_mapping() and _avar2_eval_offset() binary-search. - The estimator pulls the ascending knots back through the mapping with one forward scan over its toCoords. - Breakpoint knots are pushed and then sorted, keeping the first of equal z as _avar2_add_knot() did. An old segment map with fromCoords out of order, which the spec forbids, would still need a linear scan per lookup; for such an axis keep the {-1, 0, +1, z_old} anchors and skip the estimate. Remove HB_BUDGET_SUBSET_TABLE, now unused. test_avar2_restrict_many_breakpoints now expects the 32,769-breakpoint axis to instance, and to match, rather than fail; the whole test runs in 0.2 s. 65,000-breakpoint maps instance in under 0.25 s. Outputs are byte-identical to before for every test-subset-avar2 instance and for 317 random avar2 maps (sorted, with duplicate fromCoords, and with non-monotone toCoords) on random ranges; only maps with unsorted fromCoords differ. Tested: meson test -C build (277/277 OK). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [subset] Reuse the one bsearch loop for avar2 instead of a new one The avar2 offset-compensation searches went through a hand-rolled _avar_partition_point loop -- a second binary search living next to hb_bsearch_impl. Route them through hb_bsearch_impl instead, with comparators that never return 0 so it reports the insertion position (a lower or upper bound, per the comparator) rather than a match. No behavior change: the full test suite passes and the CWJXX1BL and 3HO8JDDV reproducers stay bounded (0.13 s CPU and 21 MB peak, the table failing cleanly), same as before. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
58bd1032a8 |
[ci] Cache amalgamated configuration builds
Use ccache for each configuration's core and subset compilation. Split core compilation from linking so ccache can store its object while retaining the existing link check and accumulated failure status. Validation: actionlint, git diff --check, and meson test -C build (302 passed, one skipped). The HB_TINY core/subset commands compile and link successfully and produce cache hits on a repeat build. Assisted-by: OpenAI Codex |
||
|
|
420bb6d0ba |
[subset/cff] Bound hint-drop/closure walks and share the budget across the whole subset (#6638)
* [subset] Bound the CFF hint-dropping and closure walks drop_hints_in_str()/drop_hints_in_subr() and the closure walk (collect_subr_refs_in_str/_in_subr) recursively walk the subroutine calls recorded for each glyph with no depth limit and no work budget. The records need not match what the interpreter executed: a string is parsed on its first run only, global subr records are shared across Font DICTs whose local subrs differ, and endchar does not end a walk. So the recorded call graph can nest deeper than kMaxCallLimit or be cyclic, and a binary-tree subr structure makes the hint-dropping walk expand exponentially. A 360-byte CID font crashed the subsetter with a stack overflow under --no-hinting (or hb_subset_preprocess), and a ~1 KB font ran unboundedly. PR #6428 rejected stack-supplied call operands but added no depth, cycle or work limit to these walks, so these fonts were still affected. Hold both walks to the interpreter's call-depth limit (kMaxCallLimit), which stops the cycle and the long chain before the stack runs out, and charge the hint-dropping walk to the subsetting pass budget introduced for the shared-subroutine work, so the exponential expansion is capped too. A walk that follows the interpreter's path stays within both, so only fonts whose records diverge from their execution are affected; over either limit the subset fails, as other CFF planning failures do. Adds test_subset_cff1_subr_loop, which subsets the 360-byte cycle font with --no-hinting and only requires that hb_subset_or_fail() returns. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-BCC7WHCA. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [subset] Stop CFF subr walks at the call-depth limit instead of failing The hint-dropping and subr-closure walks enforce kMaxCallLimit themselves, because the recorded call graph can nest deeper than the interpreter allows or be cyclic. Hitting the limit failed the whole subset, and the hint-dropping walk signalled it by writing -1 into the shared work budget, conflating "too deep" with "out of budget" and clobbering the budget for later passes. Make both walks best-effort at the limit: the closure walk keeps the subr it reached but does not walk into it, and the hint-dropping walk does not walk into the subr and keeps the call and its hints. Only running out of the work budget fails the subset now, so drop_hints_param_t no longer needs set_error() and the budget is only ever touched by hb_budget_spend(). Walks that follow the interpreter's path never reach the limit, so real fonts are unaffected; for fonts whose records diverge the output may keep a few hints or call a subr whose callees were not retained, but no longer fails. test_subset_cff1_subr_loop now also asserts that the subset succeeds; it failed before this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [subset] Share one CFF charstring budget across a whole subset Each CFF / CFF2 charstring pass of the subsetter (seac closure, CFF2 extents for instancing, CFF2 usage and instancing passes, subroutine subsetting with hint dropping, and flattening) created its own budget with CFF::get_subset_budget(), so one subset could spend that budget several times over, and the two CFF2 instancing passes reset it between them. Keep the budget on hb_subset_plan_t instead: cff_budget() sizes it on first use from the table, as before, and every pass draws on the same counter, so the total work of one subset is bounded once. Retries of a table with a larger serialize buffer draw on it too. cff1 depend() is not part of a subset plan and keeps its own budget per call. Real fonts use about 1.5 operations per table byte per pass, against a budget of 32 per byte (at least 2^24). Tested: full meson test and the subset suite; hb-subset on SourceSerif4Variable-Roman.otf (CFF2), Roboto-Regular.otf (CFF), NotoSansCJKhk-VF.otf (30 MB CFF2) with --gids='*' and --unicodes='*', with and without --no-hinting, --desubroutinize and partial / full instancing, and on every .otf in /Library/Fonts with --gids='*', all succeed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * [subset] Detect CFF charstring budget exhaustion at zero, not below The shared CFF charstring budget is only ever spent through the cs_interpreter_t interpret() cap, which clamps each glyph's operator count to the remaining budget and charges back exactly what it consumed. By construction it never overshoots, so an exhausted budget lands at exactly 0 rather than going negative. The exhaustion checks therefore compare budget <= 0 (cff1 depend()'s seac walk) and budget > 0 (the subset planner's seac-closure and CFF2 get_extents verdicts), not < 0 / >= 0, which that path can never reach. With < 0, cff1 depend() never failed, so hb_subset_depend_from_face_or_fail() returned a result for an adversarial font that exhausts the budget even though the equivalent subset fails; that is the test-subset-cff1 shared-subrs case on CI builds with -Dexperimental_api=true. Document this at each check. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
e7999a6e0c |
[ci] Drop unused Graphite dependency from Valgrind
The Valgrind job leaves Graphite support disabled, so its development package is unused. Remove it without changing the build or test options. Validation: actionlint and git diff --check. Tests were not rerun for this CI-only package-list change. Assisted-by: OpenAI Codex |
||
|
|
6862561787 |
[ci] Cache Cargo dependencies and Rust build artifacts
Cache downloaded Cargo sources and Meson's Rust debugoptimized target outputs, including the rebuilt standard library. Scope the cache to the compiler version and build configuration, and save updated entries for subsequent runs without caching generated bindings or Meson state. Retain the Cargo invocation so it checks source freshness after restore. Validation: actionlint, git diff --check, and meson test -C build. Remote cache restoration remains to be exercised in Actions. Assisted-by: OpenAI Codex |
||
|
|
10a61dafce |
[ci] Skip documentation and introspection in the Rust job
Disable documentation setup and GIR/typelib generation, and remove their build dependencies. The docs job covers these outputs. Retain the full Rust integration test suite, Clippy, and rustfmt. Validation: actionlint, git diff --check, and meson test -C build. Assisted-by: OpenAI Codex |
||
|
|
2c19f67a81 |
[ci] Reduce CIFuzz runs to five minutes
Set fuzz-seconds to 300 instead of 600 to shorten pull-request feedback. Validation: actionlint and git diff --check. Tests were not rerun for this CI-only duration change. Assisted-by: OpenAI Codex |
||
|
|
e3773b5090 |
[ci] Cancel superseded pull-request workflow runs
Group pull-request runs by workflow and PR number so new commits cancel older queued or running checks. Give non-PR runs unique groups, leaving main-branch builds and tag releases independent. Validation: actionlint; workflow concurrency assertions; meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex |
||
|
|
7774c667eb |
[ci] Separate compiler caches by workflow
Linux and Rust shared a cache key, while Valgrind used the unscoped default. Include the workflow name in cache keys consistently and give Linux and Rust 1G each, since their 500MB caches were full in PR #6637. Validation: actionlint; meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex |
||
|
|
d5db4e3d5c |
[ci] Use ccache with explicitly selected Clang compilers
Setting CC and CXX prevents Meson from automatically enabling ccache. Wrap both compilers explicitly and isolate each sanitizer's cache. Validation: actionlint; standalone Meson ASan/UBSan C/C++ build and cache hits on rebuild; meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex |
||
|
|
dad381f0c0 |
[ci] Cache MSYS2 compiler outputs by toolchain
Install the native ccache package for each MSYSTEM and persist its workspace cache separately for MINGW64 and CLANG64. Check compiler contents across package updates and report compiler-cache statistics. Validation: actionlint; YAML assertions; meson test -C build (302 passed, one skipped). Native MSYS2 validation remains in CI. Assisted-by: OpenAI Codex |
||
|
|
2903e08a45 |
[ci] Trim MSVC fallback dependencies
Disable Cairo and dependency tests for GLib and libffi. Keep GLib so HarfBuzz's API tests, including DirectWrite, still build and run under MSVC. MSYS2 continues to cover the Cairo integration on Windows. Validation: actionlint; meson test -C build (302 passed, one skipped). Native MSVC validation remains in CI. Assisted-by: OpenAI Codex |
||
|
|
920baf5d1b |
[ci] Route MinGW cross-compilation through ccache
Meson does not automatically prepend ccache to compilers selected in a cross file. Generate a CI-only overlay with explicit compiler wrappers and isolate the cache by target architecture. Keep the regular cross files usable without ccache installed. Validation: actionlint; C/C++ Meson cross-builds for i686 and x86_64, including cache hits on rebuild; meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex |
||
|
|
6520c76a16 |
[ci] Skip Pixman tests and demos in Windows bundles
The cross-build only runs HarfBuzz's test suite, but Pixman still builds its own tests and demos by default. Disable both, including their shared test utilities, while retaining the libraries used by Cairo. Validation: Pixman 0.43.4 Meson setup and target introspection; bash -n .ci/build-win.sh; meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex |
||
|
|
bd3f06f232 |
[ci] Let Meson choose Windows cross-build parallelism
Remove the three-job limit left over from CircleCI. The Windows cross build now runs on GitHub Actions and can use Meson's default parallelism. Validation: bash -n .ci/build-win.sh; meson test -C build (302 passed, one skipped). Assisted-by: OpenAI Codex |
||
|
|
41a2880106 |
[CFF2] Charge blend region-scalar and default-value evaluation to the budget (#6637)
* [CFF2] Charge blend region-scalar evaluation to the work budget cff2_cs_interp_env_t::process_blend() evaluates one VarRegionList scalar per entry of the VarData's region indices (up to 65535, each walking up to axisCount axes) the first time a charstring hits `blend`, but the only budget charge for blend is the operand-proportional one in cff2_cs_opset_t::process_blend(), which runs afterwards and is skipped when the operand check fails. So `1 blend` did regionIndexCount x axisCount scalar evaluations for one budget unit, and a VARC fan-out re-ran it tens of thousands of times within 2% of HB_BUDGET_GLYPH. Charge region_count x max(1, axisCount) through the env's existing spend_budget() right before resizing and filling the scalars vector, matching how VARC charges values x coords for its own ItemVariationStore evaluations; a failed charge errors the interpreter exactly as a failed resize does. spend_budget() is a no-op without a budget, so the subsetter and instancer paths are unchanged, and seen_blend gates the work to once per charstring run. Adds test_hb_draw_cff2_blend_region_budget: a CFF2 charstring blending one value over 256 region indices of a 16-axis region list must consume at least 256 x 16 units and fail under a 2048-unit budget. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-WSM91D3G. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [CFF2] Charge the blend default values to the work budget cff2_cs_opset_t::process_blend() walks all (k+1)*n values of a blend (n default values plus k deltas each) but charged only the k*n deltas, total - n. With a VarData of regionIndexCount 0 (or no variation store) k is 0, so `n blend` charges nothing, pops nothing, and the same operands can be blended again and again for the price of two tokens. Charge `total` = (k+1)*n, exactly what the loop touches. spend_budget() is a no-op without a caller budget, so only budgeted callers (draw, extents, paint, shape, and the subsetter passes that now pass a budget) are affected, and a well-formed charstring pays one extra unit per blended value. Adds test_hb_draw_cff2_blend_budget: a charstring that pushes 100 numbers and blends them 100 times over a region-less VarData must consume at least 100 x 100 units and fail under a 5000-unit budget. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-0DAQUESS. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
6aa278829e |
[subset] Charge gvar avar2 culling pass to the source table size (#6641)
In a well-formed gvar the per-glyph data ranges [offset[i], offset[i+1]) are disjoint, so the retained glyphs' data add up to at most the table. gvar::subset()'s avar2 culling pass used the offsets as they are, so malformed offsets (0, D, 0, D, ...) could point thousands of glyphs at one 128 KB block; the pass parsed, rewrote and kept a heap copy of it once per glyph, repeated on each of the serializer's buffer-doubling retries (26 s and 1.3 GiB from a 251 KB font before it was rejected). Restore the invariant where the pass is driven: charge each retained glyph's byte length to a budget equal to the source blob length with hb_budget_spend(), and on exhaustion raise HB_SERIALIZE_ERROR_OTHER so _hb_subset_table_try() does not retry. A spec-conforming table can never reach the limit, so there is no tuning constant and valid fonts subset byte-identically; a font whose retained glyphs' gvar ranges overlap by more than the table length now fails avar2 partial instancing. Adds test_avar2_culling_aliased_gvar_data to test/api/test-subset-avar2.c. The non-avar2 instantiate() branch trusts the same offsets and is not touched here. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-NJZQ4XFP. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
a1134fa3ea |
[subset] Budget kept glyf points and the avar2 reachable-range computation (#6640)
* [subset] Budget the glyf points a plan keeps for partial instancing For partial instancing the subset plan decodes every retained glyph through Glyph::get_all_points_without_var() and keeps all the points in plan->new_gid_contour_points_map until the plan is destroyed. That caller passed no work budget, and nothing capped the total. A simple glyph of repeated flags declares ~65536 points in ~526 bytes, and a loca whose offsets alias one another lets many glyph ids share those bytes, so a 25 KB font drove plan creation to 2.2 GB. PR #6256 added a charge-before-allocate budget to SimpleGlyph::get_contour_points() and passed it from the draw/extents path, but left this subsetter caller unbudgeted. Give the loop one plan-wide budget, the larger of HB_BUDGET_SUBSET_CONTOUR_POINTS and the source glyf length, and charge each glyph's decoded points after it is decoded. One glyph's decode is bounded by the format (about 786 KB), so the transient is proportional to the input; the budget bounds what the plan retains. Exhausting it fails plan creation, the same outcome as any other decode failure in this loop. Ordinary glyph data carries at least one byte per point, so the size-derived bound does not constrain well-formed fonts. Adds an API regression test (test_subset_gvar_shared_glyph_data) with an aliased loca over a 65536-point simple and composite glyph. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-O2ZFVVUI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [subset] Budget the avar2 reachable-range computation _compute_avar2_reachable_ranges() bounded only the breakpoint grid (MAX_GRID = 16384 vertices), while its real work is axes x vertices x active row columns x tents. A delta-set row may list the same region tens of thousands of times, and a clamped DeltaSetIndexMap lets every fvar axis share that one row, so a 50 KB font cost about two minutes of CPU per hb_subset_plan_create_or_fail(). Charge one shared allowance per plan, HB_BUDGET_SUBSET_AVAR2_RANGES, at the three places the work is created: scanning the row's columns into the active set, collecting each active region's tents, and the exact grid enumeration (charged up front as grid_size x (active + tents)). Degradation reuses states the surrounding code already handles: an axis whose exact enumeration does not fit takes the existing interval-arithmetic bounds (still conservative, so the instance stays correct), and once the allowance is gone the remaining axes are left unconstrained. The hostile fonts now finish in well under a second; real avar2 fonts use a small fraction of the budget and their output is unchanged. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-3VDGZ019. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [subset] Guard against null glyf blob in contour-point budget get_instance_glyphs_contour_points() sizes its op budget from the source glyf table length. When head.glyphDataFormat (or indexToLocFormat) is out of range the glyf accelerator is disabled and reference_glyf_table() returns no blob, so hb_blob_get_length() then dereferenced a null pointer and crashed during partial instancing. Take the length only when the blob is non-null. Add a regression test that builds a variable font with an invalid glyphDataFormat and plans a partial instance. Reported by Anthropic's OSS Scanner. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [subset] Document that the avar2 range budget fallback is safe Running out of HB_BUDGET_SUBSET_AVAR2_RANGES returns early from _compute_avar2_reachable_ranges() and records nothing for the remaining axes. That does not produce a wrongly instanced font: avar2_reachable_ranges is only used to cull variation data that cannot be reached, and an axis without a range is never culled (_hb_avar2_region_is_dead() skips it, the same as the VARC path that resets the map). A pinned axis that is not detected as self-contained stays in fvar as a hidden pin, which is what CFF2 fonts always get. The output is correct, only larger. Likewise the exact-grid fallback uses interval bounds, which are conservative. Say so in the comments instead of "left unconstrained". Tested: meson test -C build (278/278); hb-subset --instance wght=400 and wght=300:700 on GoogleSansFlex, NotoSansKR and SourceSerif4 variable fonts, all glyphs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
7b30ba988d |
[instancer] Budget VarStore rebuild, tuple splitting and per-point tuple expansion (#6639)
* [subset] Bound the dense delta matrix when rebuilding a VarStore item_variations_t::as_item_varstore() allocates one int per (row, region) pair for the whole rebuilt ItemVariationStore, every row as wide as the full region list. In the font a row only pays for the regions of its own VarData (possibly none, and several dataSets offsets may share one VarData), so the row count and the region count are independent and their product is unbounded: a ~120 KB font drove the allocation to 2.4 GB, and a 972-byte font with region-less rows to ~800 MB. Bound the matrix before allocating it, at the single site all instancing callers (MVAR, HVAR/VVAR, GDEF, BASE, COLR, avar) pass through: HB_SUBSET_MAX_VARSTORE_ROWS (1<<21, which also bounds the per-row hb_vector_t overhead and catches the zero-width-row variant) and HB_SUBSET_MAX_VARSTORE_DELTAS (1<<26 cells, 256 MB of int), computed in 64-bit. These are flat ceilings on this one allocation rather than a bound proportional to the source size: optimizer output routinely has several VarData over disjoint region subsets, so the dense matrix is legitimately much wider than any single VarData and a proportional bound would reject it. No store in the test fonts comes near the cell cap. Returning false is the path a failed resize() already takes, and every caller drops the table on it. Rows are fixed-width, so they are now allocated with resize_exact(), removing the ~19% growth slack per row. The cap bounds the amplification rather than removing it (a ~75 KB font just under the cell cap still peaks around 265 MB); the structural follow-up is to stop making every row as wide as the whole region list. Adds a unit test (test_delta_matrix_limits) covering both caps and an under-cap case. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-0ZZNV0U6. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [instancer] Budget tuple splitting when narrowing axes Narrowing an axis makes change_tuple_variations_axis_limits() replace every tuple whose region uses that axis with up to six tuples (rebase_tent solutions), axis after axis with no merging, so one region spanning N narrowed axes becomes up to 6^N tuples, each with its own copy of the axis map and deltas. A 364-byte font with a region on 8 narrowed axes drove one hb_subset_or_fail() call to 9 s of CPU and 1.7 GB. The only existing limit, the subset output buffer cap, is checked after the whole instantiation has run. Charge the copies to a cumulative budget held in optimize_scratch_t, which every caller (gvar, cvar, CFF2, and item_variations_t for GDEF/HVAR/MVAR/BASE/COLR) already keeps for one whole table. The budget starts at HB_BUDGET_INSTANCER_MIN and earns HB_BUDGET_INSTANCER_FACTOR times the cost of each source tuple; each split spends out[0].get_cost() x (out.length - 1) through the existing hb_budget_spend() helper, and the function returns false when the budget is spent, which all callers already treat as failure. The cost (32 + 8 per axis + 1 per row/point) scales with what a copy allocates for both ItemVariationStore and gvar tuples, so the budget also bounds a store with many VarData and a gvar with many glyphs. An instancing request whose splits exceed the budget (roughly more than 64 copies per source tuple beyond a 4M-unit floor) now fails instead of producing a store that could not be serialized anyway. Normal fonts stay far below the floor, so the subset suite's partial-instance tests are byte-identical. Adds a unit test (test_tuple_split_budget) with a tent on 16 axes. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-X7UB9BVO. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [subset] Budget the dense per-point expansion of gvar/cvar tuples create_from_tuple_var_data() expands every tuple to arrays with one entry per point of its glyph (per cvt value), however few points the tuple actually names, and keeps them until the table is serialized. The tuple count (12-bit) and point count (16-bit) are each bounded per glyph, but their product and its sum over the table are not, and neither factor costs many font bytes: 15 bytes of gvar can expand to ~590 KB, and a 31 KB font reached 2.1 GiB. Give the decode a per-table points budget, HB_BUDGET_SUBSET_TUPLE_POINTS_FACTOR per byte of the source table floored at HB_BUDGET_SUBSET_TUPLE_POINTS_MIN, owned by glyph_variations_t for gvar and a local in cvar::subset(), and charge point_count per decoded tuple before expanding it. Exhausting it returns false exactly like the function's existing allocation-failure paths (the table is dropped from the subset). Real gvar tables expand to only a small multiple of their byte size, so the factor leaves ample headroom. The extra copies made when a range limit splits a tuple are already bounded by the instancer split budget in optimize_scratch_t, so they are not charged here again. Adds a unit test (test_tuple_points_budget) covering the decode charge. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-8CH2PGW8. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
a6beb11493 |
[subset/cff] Bound parsed subrs and share one charstring budget per pass (#6636)
* [subset/cff] Bound parsed subroutines by the table size before allocating
subr_subsetter_t::subset() resizes one parsed_cs_str_vec_t per Font DICT
to that DICT's localSubrs->count, assuming the sum is bounded by the
table. It is not: any number of Font DICTs may point at the same
Private DICT and Subrs INDEX, so a 500 KB font with 16 Font DICTs all
sharing one 1000-subr INDEX cost about 1.6 GiB (measured: control 10
MiB, shared 1651 MiB; 2.8 GiB with hb_subset_preprocess).
Sum the global plus per-Font-DICT local subroutine counts in 64-bit
before any per-Font-DICT allocation, and fail the subset when the
records would exceed 256 bytes per byte of the source table, the same
ratio _hb_subset_table_try() uses to stop growing the output buffer.
A font whose Font DICTs do not share their Subrs needs at least one
table byte per subroutine, so it stays far below the limit; every
CFF/CFF2 font in the test corpus is at most a couple of bytes per table
byte. Over the limit the subset fails, as any CFF planning failure has
since dde7da182e; the shared font now peaks at 7 MiB instead of 1.6 GiB.
The check sits before the allocations in the non-accelerator branch, so
it also covers the hb_subset_preprocess path and both CFF1 and CFF2
instantiations of the template; the --desubroutinize flattener path
does not allocate per subroutine and is unaffected.
Adds test_subset_cff1_shared_local_subrs: a 16-Font-DICT CID font with
1000 local subrs subsets when the subrs are unshared and fails when
every Font DICT shares them.
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-HPFG1IAV.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* [subset] Share one CFF charstring work budget across a subsetting pass
Every per-glyph charstring loop in the subsetter (subr_subsetter_t::
subset, subr_flattener_t::flatten, the two CFF2 partial-instancing
passes, the CFF2 instance-metrics loop, and the CFF1 seac closure in
the plan and in the depend builder) created a fresh interpreter bounded
only by HB_CFF_MAX_OPS per charstring. Glyphs can share subroutines,
so a font where every glyph makes one cheap call into a deeply nested
shared subr cost num_glyphs x ~200,000 ops: a 121 KB, 30,000-glyph font
took 33 s to subset (control 0.05 s).
Give each pass one cumulative counter, max(HB_BUDGET_SUBSET_CFF = 2^24,
32 ops per table byte), threaded through cs_interpreter_t::interpret()'s
existing budget argument exactly as the outline and extents paths do.
When it runs out, interpret() fails as it does for a single over-limit
charstring, so the CFF/CFF2 table fails to subset (the subset fails, as
any CFF planning failure has since
|
||
|
|
db38d0c7e0 |
[layout] Charge the skip, skipped-record and ligature walks to max_ops (#6634)
* [test] Force the ot shaper in the layout budget tests
test_ot_layout_gpos_mark_base_rescan_budget calls hb_shape() with no
shaper forced, then asserts an OT-specific max_ops trip via
hb_buffer_allocation_successful(). Under the HarfRust shaper
(HB_SHAPER_LIST=harfrust, as the rust CI job re-runs the api suite)
it aborts, because harfrust shapes independently and never reaches
the C-side max_ops paths it tests.
Shape with hb_shape_full(..., {"ot", NULL}) so it exercises the OT
shaper regardless of the configured shaper list, as
test_shape_lookup_budget already does.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* [layout] Charge the skip, skipped-record and ligature walks
The per-pass `len / 16` charge does not bound per-position inner work:
the skipping iterator's rescans over default-ignorables, apply_lookup's
walk over a rule's skipped LookupRecords, and match_input /
ligate_input's walk over a ligature's components and marks. Each is a
CPU-DoS a crafted font triggers under the default max_ops.
Charge each on its work path only, so honest shaping is unaffected:
skipping_iterator_t::next/prev charge one op per skip (a first-try
match charges nothing); apply_lookup charges each skipped record;
match_input charges the ligbase backward walk and ligate_input the
mark re-adjust walk, once each.
Reproducers drop from 20 s / 6.8 s / 3.8 s to 0.05 s / 0.003 s /
0.02 s; in-house and aots shaping tests pass with no output change
(the pre-existing text-rendering-tests failures are unchanged).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* [layout] Stop matching once the skip/walk budget is spent
The previous commit charged the walks, but the skipping iterator's skip
arm only decremented max_ops; within one pass a tiny aliased font could
still re-run a walk per candidate, per rule or per subtable without bound
(dfrg's harfrust #604 review found the same gaps here).
Flag the buffer unsuccessful when the skip arm spends the budget -- it
still never early-returns, so *unsafe_to stays set for the kern machine --
and stop the loops that repeat walks once it clears: apply_backward,
Ligature::apply, the reverse-chain and mark-base/lig subtable applies,
and context_apply_lookup / chain_context_apply_lookup. apply_forward
already checks successful.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* [layout] Enforce the budget in the shared subtable loop
dfrg's re-review (harfrust #604): the per-kind entry guards miss paths
that scan before reaching them -- context format 3, the context/ligature
pre-match scans, cursive and mark-to-mark -- so a lookup aliasing thousands
of subtables restarts a buffer scan at each one. Guard the shared
accelerator apply instead (hb_applicable_t::apply), and drop the
now-redundant reverse-chain and mark-base/lig entry guards it subsumes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
|
||
|
|
33d859b259 |
[ci] Consolidate lightweight compile checks (#6650)
Run the six configuration variants in one job and the four C++ compiler/standard variants in another. This removes eight runner requests per push or pull request while retaining all compile checks. Group logs by variant and accumulate failures so later checks still run. Validated all 16 compile/link checks locally, workflow Bash syntax, compiler-failure propagation, and actionlint with the existing ubuntu-26.04 runner label allowed. Fixes: https://github.com/harfbuzz/harfbuzz/issues/6649 Assisted-by: OpenAI Codex |
||
|
|
8d01a1b148 |
[subset/cff2] Budget the region transforms built for partial instancing (#6635)
cff2_instancing_plan_t::create() builds k identity tuples of k cells (then keeps a k-float column per surviving solver tuple) for every entry of the CFF2 ItemVariationStore's VarData offset array, and nothing bounded k (a 16-bit region count), the number of entries, or their aliasing of one VarData. The work is therefore quadratic in a font field, so a 12 KB font cost 2.2 GB. Charge those cells, before they are allocated, to a per-table budget HB_BUDGET_SUBSET_CFF2_CELLS (2^24 cells) via the existing hb_budget_spend helper, at both allocation sites (the k*k identity tuples and the surviving solver columns). Exhausting it fails create() like any other planning failure, so the partial instance fails safely (bounded at ~175 MB worst case) instead of exhausting memory. Adds test_instance_cff2_vardata_budget: a 6.8 KB font with 40 offsets aliasing one unused 800-region VarData must fail to partially instance rather than build a region transform for each; it succeeds (keeping CFF2 at hundreds of MB) before this change. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-I7KWU2X6. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
a9faca23bc |
Merge pull request #6633 from harfbuzz/split/layout-depend-recursion
[depend] Bound dependency recursion depth and whole-table path count |
||
|
|
79146f902e |
[depend] Bound lookup recursion depth and whole-table path count
hb_depend_context_t::recurse() only refused to re-enter a lookup already on the call stack, so a chain of distinct Context lookups recursed once per lookup (stack overflow around 8600 lookups on an 8 MB stack) and lookups invoking each other in every order were walked once per ordering (a factorial number of interned paths, gigabytes of memory). recurse() is where every sibling context (closure, closure-lookups, apply) enforces HB_MAX_NESTING_LEVEL, so add the same nesting_level_left guard here; shaping never applies lookups nested deeper, so no edge the closure can reach is lost (a chain's final edge drops at exactly the depth the closure stops, 65->66). Bound the number of distinct recursion paths with a counter kept over the whole table (not cleared by reset_recurse_cache, which runs per top-level lookup) against a new HB_MAX_DEPEND_RECURSE_PATHS limit in hb-limits.hh, so it can be tuned on its own; exceeding it fails the build so hb_subset_depend_from_face_or_fail() returns nullptr instead of emitting a truncated graph. The largest whole-table path count among the test fonts is 744 (NotoNastaliqUrdu-Bold), so 35000 leaves ample headroom. Builds only with experimental_api. Adds a small permutation-font fuzz seed and a test-ot-depend test; test-ot-depend, the depend fuzzer and the depend-closure-parity tests pass. Related to PR #6185. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-N28924W8. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
c611a0589d |
[depend] Release oversized recursion maps in reset_recurse_cache()
reset_recurse_cache() runs once per top-level lookup and cleared completed_recursions and recurse_path_to_index with hb_hashmap_t::clear(), which walks the whole table and keeps its allocated capacity. A single lookup that grew these maps large therefore made every later top-level lookup pay to walk that full capacity, however little it recursed, giving a font with one busy lookup followed by many trivial ones a CPU DoS in hb_subset_depend_from_face_or_fail(). Add clear_or_release(): when a map is large but was left mostly empty by the lookup that just finished, swap in fresh storage before clearing, so later lookups start from a small table. Adds a fuzzer regression font. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-PNJPHF76. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
b90abaa791 |
Merge pull request #6632 from harfbuzz/split/layout-apply-budget
[layout] Charge GSUB/GPOS lookup apply and mark rescans to max_ops |