There is one known difference before and after the change that comes
from 32bit/64bit machines difference on long size which is documented
in the tests.
Previously it was changing value's pointer even if the parsing
was declarad a failure, this fixes it by changing the value
only if the parsing was successful.
Once the project was avoiding STL and everything related at all cost
but now use of std:: provided things exists on the project despite
still no runtime dependency to STL (which is fantastic) and
since this in tests and even this doesn't pull STL, use of std::
should be okay to resolve the issue some of the CI bots have with
accessing signbit and isinf (unlike my local machine which is ok).
m.set (99, m.get (1)) passes a reference into the map's own items
array. If the insertion needs to grow the table, alloc() frees that
array before the value is read, so set_with_hash() copies from freed
memory. Same for the key, eg. m.set (m.get (1), v).
When growth is needed and the key or value lies within our storage,
copy them out first and insert the copies. The copies are
default-constructed and then assigned, matching how items are filled,
since some key types (eg. OT::OffsetTo) are not copy-constructible.
Added test-map cases for value and key aliasing, including a
non-trivial value type. Reproduced with ASan before the fix; test-map
is clean under ASan+UBSan after it, and meson test passes.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* [meson] Skip vector tests when vector is disabled
The vector budget test was built unconditionally even when vector was
explicitly disabled. Its empty dependency supplied neither include paths
nor libraries, breaking otherwise valid reduced-feature builds.
Skip the vector test directory when the library is disabled. Add a Linux
CI build and test pass with vector disabled to cover this configuration.
Reproduced the missing hb.h failure on Linux before the fix. The full
suite with vector, raster, and GPU disabled passed 229 tests with one
skip; all three vector tests passed with vector enabled.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6277
Assisted-by: OpenAI Codex <codex@openai.com>
* [ci] Remove extra vector-disabled build pass
Keep the fix focused on guarding the vector test directory without adding
another build and test pass to the Linux workflow.
CI-only change; the previously validated Meson guard is unchanged.
Assisted-by: OpenAI Codex <codex@openai.com>
* [meson] Guard dependency fuzzers when subset is disabled
With experimental APIs enabled, dependency fuzzers referenced
libharfbuzz_subset even when the subset library was disabled, causing
Meson setup to fail with an unknown-variable error.
Require subset support when building the dependency fuzzers and when
registering their tests.
Full tests with experimental APIs enabled: 92 passed with subset
disabled, and 247 passed with subset enabled. Both dependency fuzzers
and their 13 tests remain registered in the enabled configuration.
Assisted-by: OpenAI Codex <codex@openai.com>
Adding a sorted array to an inverted set delegates to the underlying deletion path, but set_sorted_array() always added bits. Excluded members stayed excluded, and existing included members could become excluded.
Use the requested bit value, as set_array() already does. The regression covers duplicates, excluded and included members, and both existing and absent pages.
Assisted-by: OpenAI Codex
Copy assignment resets the destination before reading the source. When
they are the same vector, this also clears the source. In particular,
hb_set_set(set, set) loses the set's stored pages.
Return immediately for self assignment. Cover trivial and nontrivial
vector elements and public set assignment in both inversion modes.
Validation: both regressions fail before the fix; meson test -C build
passes (261 passed, 1 skipped).
Assisted-by: OpenAI Codex
Deleting the last member of a page leaves an empty page in the sparse set. `hb_bit_page_t::get_max()` returned zero for that page, so reverse iteration could report a value that was never in the set. For example, add and delete 512, then iterate backward from 1024: HarfBuzz reported 512 from an empty set.
Return INVALID for an empty page, matching get_min(), so previous() skips it. Cover reverse scalar/range iteration with retained empty pages, including inverted sets.
Assisted-by: OpenAI Codex
The mixed-inversion equality path compares zipped iterators, which stop
at the shorter set. An empty set therefore compares equal to a full
inverted set, as does any matching finite prefix.
Check populations before comparing members and add regression coverage
for empty sets and matching prefixes in both argument orders.
Validation: meson test -C build (261 passed, 1 skipped).
Assisted-by: OpenAI Codex
When the cursor's page is absent, bfind selects the next stored page.
Using the cursor's offset in that different page can skip its members,
or skip the entire page when the cursor ends on a page boundary.
Apply the cursor offset only when the selected page matches its major
index. Cover batch and scalar iterator agreement across missing pages
for both ordinary and inverted sets.
Validation: the new regression fails before the fix; meson test -C build
passes (261 passed, 1 skipped).
Assisted-by: OpenAI Codex
* [machinery] Don't cache the Null object in face accelerator loaders
When libharfbuzz and libharfbuzz-subset (or raster, vector, gpu,
cairo) are separate shared libraries, each has its own hidden
_hb_NullPool. If an accelerator's allocation failed, the lazy loader
stored the calling library's Null object in the face. When the face
was later destroyed from the other library, do_destroy () did not
recognize that Null object and ran the destructor on read-only
memory.
hb_face_lazy_loader_t's create () only fails on allocation failure,
so stop storing get_null () there and retry on next access instead.
A stored instance is now always a real object. Other loaders, whose
get_null () is a shared static default, keep caching it. The
success path and get_relaxed () are unchanged.
Since a failed load no longer leaves anything behind for
get_relaxed (), the subsetter, which runs closure_lookups () on its
own GSUB/GPOS blob and recurses through the face accelerator with
get_relaxed (), now forces the accelerator to load through the public
hb_ot_layout_has_substitution/positioning () and fails the plan if
it is missing. Calling get () from libharfbuzz-subset is not an
option since the accelerator constructor uses a hidden symbol.
Testing: the six hb-subset-fuzzer crashes against a shared-library
ASan build (write to _hb_NullPool in hb_ot_face_t::fini ()) no
longer reproduce. A deterministic regression test is not practical
since it needs a specific allocation to fail in a process using two
of the shared libraries. meson test: 261 passed, 1 skipped.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6324
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* [machinery] Cache failed face accelerators as a tagged Null pointer
The previous commit stopped caching the Null object when a face
accelerator failed to allocate. That made repeated accesses to the
same accelerator inconsistent under OOM: a failed get () returned
Null and a later one could retry and succeed. CIFuzz found the
subset driver taking its table from one access and its blob from the
next, then subsetting with the Null CFF1 accelerator (null fdSelect).
Many places access an accelerator more than once, so fixing callers
one at a time is not viable.
Revert that, and the subsetter guard it needed, and instead cache the
failure as get_null () with its low bit set. get_stored () and
get_stored_relaxed () mask the bit off, so every access keeps seeing
the same object, and do_destroy () skips tagged pointers by the bit
rather than by comparing against this library's Null address. That
comparison is what failed when libharfbuzz and libharfbuzz-subset
(or raster, vector, gpu, cairo) are separate shared libraries, each
with its own _hb_NullPool.
Only hb_face_lazy_loader_t opts in; other loaders compile as before.
A loader instance must stay one pointer in size, so the flag is
carried in the pointer rather than a separate member. The tagged
pointer only ever refers to the static Null object, never to heap
memory.
Testing: the CIFuzz testcase no longer reproduces (static and shared
ASan builds), nor do the six shared-build hb-subset-fuzzer crashes.
meson test: 261 passed, 1 skipped.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/6324
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
ff9183045f commented out the unused GET_METRIC_X in
_hb_ot_metrics_get_position_common () to silence -Wunused-macros,
but the trailing backslashes on the // lines then triggered gcc's
-Wcomment. Delete the dead macro and its matching #undef instead.
meson test: 261 passed, 1 skipped; no warnings from hb-ot-metrics.cc
with -Wunused-macros.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Resolve condition-evaluation conflicts while preserving the layout
instancing fixes and main's double-precision and static VARC support.
Tests: full Meson suite (279 passed), and C++11 syntax checks with
HB_NO_VAR, HB_NO_SUBSET_LAYOUT, and HB_OPTIMIZE_SIZE.
Assisted-by: OpenAI Codex <codex@openai.com>
Adding a fractional pinned delta to a large condition default in float
loses its low bits. A scaled 32-bit bias also loses bits when stored in
float tuples, and float variation-store accumulation can erase small
residuals when large deltas cancel.
Use double accumulation for layout condition evaluation and instancing,
keeping ordinary positioning and region-scalar arithmetic unchanged.
Split large biases into float-exact parts, which integer row assembly
combines before serializing a single neutral-region delta.
Add large-default fractional fixtures for GSUB and GPOS, with both
legacy and additive feature variations. Test a positive 1/12288 residual
at cancellation, partial and repeated instancing, and direct evaluation
of 32-bit variation deltas outside float's exact integer range.
Tests: full Meson suite (279 passed), sanitized item-varstore tests,
C++11 reduced-feature checks, and sanitized allocation sweeps over the
new fixtures (2334 full-font attempts and 21 row-encoder attempts).
Assisted-by: OpenAI Codex <codex@openai.com>
The PairPos allocation sweep exposed a pre-existing serializer assertion.
A failed class-map allocation supplies invalid class indices, which are
then reported as integer overflow. Continuing with that recoverable error
can unbalance nested serializer objects before a snapshot rollback.
Propagate class-map allocation errors before remapping or serializing
indices. Also propagate failure to collect PairPos format-2 columns so
an empty vector cannot silently omit the positioning matrix.
Add a failed-map regression. Tested with the full Meson suite (279
passed), C++11 reduced-feature checks, and Address/UndefinedBehavior/
LeakSanitizer allocation sweeps over the new fixtures (2334 attempts).
Assisted-by: OpenAI Codex <codex@openai.com>
Several tuples can contribute to one region column. Select long-word
encoding from the accumulated cell and reject signed 32-bit overflow
instead of overflowing the addition.
Check row-vector and deduplication-map errors before testing whether
any rows remain. Otherwise a failed first row allocation looks like
an empty subtable and its error can be cleared on the next iteration.
Add accumulated-width and overflow tests. A sanitizer allocation sweep
reproduces the silent success before the fix and rejects every failed
allocation in the one-row encoder afterward (21 attempts).
Tests: full Meson suite (279 passed), sanitized item-varstore tests,
and the row-encoder allocation sweep.
Assisted-by: OpenAI Codex <codex@openai.com>
GSUB conditions need GDEF's remapped indices and precise condition
values, just as GPOS does. With avar2, GDEF waits for avar, allowing
GSUB to run first unless its dependency is explicit.
Add GSUB to the GDEF dependency and generate identity-avar2 fixtures
for legacy and additive feature variations in both layout tables.
The regressions compare shaping after partial and repeated instancing.
Tests: full Meson suite (279 passed).
Assisted-by: OpenAI Codex <codex@openai.com>
Instancing can add base fields absent from the source value format.
Matching the original format after an early PairSet or class row is
therefore no longer an upper bound on the effective output format.
Disable the early exit when a variation-delta map is supplied. Add
regressions for both PairPos formats and both value records, with a
zero pinned delta in the first row and a nonzero delta in a later row.
Tests: full Meson suite (279 passed), including the new regressions.
Assisted-by: OpenAI Codex <codex@openai.com>
Two fuzzed fonts whose GSUB has lookups with types like 3586 (0x0E02)
and 7432 (0x1D08). HarfBuzz's sanitizer rejects the table, so the text
shapes to .notdef glyphs with no lookups applied. HarfRust truncated the
type to u8 and ran them as types 2 and 8 (MultipleSubst and
ReverseChainSingleSubst): a single "A" became 2048 glyphs
(harfbuzz/harfrust#484).
Tested with `meson test -C build` (harfbuzz suites: 252 ok, 8 skipped).
Assisted-by: Claude
Convert COLRv1 clip bounds with the existing equivalent position
rounding helper, retaining saturating width/height subtraction.
This removes four roundf calls from each color glyph extent query.
Seven CPU-pinned repetitions, confirmed against a repeated baseline,
improve the 3845 color glyphs of Noto COLRv1 from 284.5 to 237.5 us
(16.5%). Whole-font extents improve about 1%; Bungee controls without
COLRv1 clip boxes remain within measurement noise.
All glyph extents match across 36 color-font/scale/location cases,
and the original 144 metric snapshots are unchanged. Rustfmt and
the full Meson suite pass (281 tests, one skip). A local Clippy
compiler crash cleared on rerun with a larger stack.
Assisted-by: OpenAI Codex
Fonts without CBDT or sbix data still queried ppem before returning
from bitmap painting. Move the query into the optional strike lookups.
Keep the existing CBDT preference and bitmap glyph handling.
Unsupported painting in benchmark-font improves about 9-12% across
the fixtures. These fonts contain no color glyphs, so this measures
the early-return path rather than bitmap rendering.
The full Meson suite passes (281 tests, one skip), rustfmt passes,
and all 144 font/scale/location metric snapshots are unchanged.
Assisted-by: OpenAI Codex
Move the ppem query into the optional bitmap-strike lookups. Fonts
without sbix or CBDT strikes no longer cross the FFI boundary to read
ppem for every extent query. Strike preference and extents are
unchanged.
CPU-pinned comparisons improve unvaried glyf extents and vertical
origins by about 2%, with no material CFF or varied-outline regression.
The full Meson suite passes (281 tests, one skip), rustfmt passes, and
all 144 font/scale/location metric snapshots match.
Assisted-by: OpenAI Codex
Use the equivalent saturating integer conversion for both axes of the
read-fonts scale adapter. This avoids roundf calls when scaling extents,
vertical advances, origins, and font bounds.
Repeated CPU-pinned benchmarks improve unvaried glyf extents and vertical
origins by about 9-10%. All 144 metric snapshots remain unchanged. The
full Meson suite passes (281 tests, one skip), with opt-level=0 for release
Clippy's nightly compiler workaround; the library stays optimized.
Assisted-by: OpenAI Codex
Float rounding accounts for about a third of static horizontal advance
lookup time. Bias in f64 before the saturating integer conversion to
preserve ties away from zero without calling roundf for each glyph.
Using f64 also preserves values immediately below half-integers.
An exhaustive comparison of all f32 bit patterns produces the same
integer results. All 144 font/scale/location metric snapshots match.
The full Meson suite passes (281 tests, one skip); release Clippy uses
opt-level=0 to work around a nightly compiler hang. Library and benchmark
builds remain optimized.
Assisted-by: OpenAI Codex
Overlapping bounding ranges do not imply that strided input and output
slots overlap. For equal strides, check field separation modulo the
stride, including the gap across record boundaries. Share this check
between advances and vertical origins.
Cover interleaved glyph/position records and hb-ot-normalize's mapping
from codepoint to var1.u32 within the same glyph-info array.
Tests: full Meson suite (281 passed, 1 skipped), using opt-level=0 for
Clippy's nightly compiler workaround. An exhaustive standalone check
covered 3,136,320 stride/offset/count layouts. Seven-run medians for
interleaved Roboto improved 2.64x for horizontal advances, 22.77x for
vertical advances, and 1.77x for vertical origins.
Assisted-by: OpenAI Codex
Register the vertical-origins batch callback. Compute X using HarfBuzz's
batched horizontal advances, then compute Y with v_origin_y_batched.
Retain HarfBuzz line and glyph-extents callbacks for fallback behavior.
Preserve scalar write order for aliased inputs, overlapping outputs, and
repeated X slots while batching normal interleaved position buffers.
Add default/varied glyf, CFF, and CFF2 coverage with strided, unaligned,
in-place, repeated, invalid-glyph, and zero-count queries.
Tests: full Meson suite (281 passed, 1 skipped); font-only Clippy; unchanged
144-case metric snapshots. Another 48 full-font batch cases (53,622 glyph
origins) matched the old scalar implementation. Clippy used opt-level=0
for the nightly compiler workaround.
Seven-run origin medians improved about 19% overall, about 36-38% for
unvaried glyf fonts; varied glyf and CFF/CFF2 remain dominated by extents.
Assisted-by: OpenAI Codex