[sanitize] Implement max offset depth - #2022
Open
cmyr wants to merge 6 commits into
Open
Conversation
Adds sanitize (recursive validation) and read_fast (unchecked construction) for the real layout tables, and ungates the `sanitize` module so it is available in normal builds. Combines the original 'Sanitize layout/...' and 'Impl FastRead for ...' commits, since read_fast is a required method on Sanitize in this design and the two are no longer separable. FastRead-era bounds (FastRead<'a> + Default) become Sanitize<'a, Args = ()> + Default; SanitizeContext gains its second (state) lifetime here too. NOTE: write-fonts/skera do not compile until the following commit.
This was only used in layout tables that now use the Sanitize equivalent.
Contributor
|
We fixed this last week in HarfBuzz: harfbuzz/harfbuzz#6116 |
cmyr
force-pushed
the
sanitize-recursion-check
branch
from
August 8, 2026 18:14
374cb0e to
a7a15b1
Compare
I thought we could put this off until colrv1, but it turns out to also be relevant for Condition tables, and there's a test in varc that explicitly builds a highly nested graph and tries to read it, which overflows. Interestingly this is okay on harfbuzz, because in harfbuzz the calls to sanitize child offsets of this table are tail calls, and so at standard optimization levels it doesn't end up growing the stack; because we call ctx.finish() after we finish with the offsets, this isn't available to us.
cmyr
force-pushed
the
sanitize-recursion-check
branch
from
August 12, 2026 19:00
a7a15b1 to
628752d
Compare
cmyr
force-pushed
the
sanitize-v3-real-tables-on-unified
branch
from
August 13, 2026 21:53
d21fae0 to
7f490ca
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I thought we could put this off until colrv1, but it turns out to also be relevant for Condition tables, and there's a test in varc that explicitly builds a highly nested graph and tries to read it, which overflows.
Interestingly this is okay on harfbuzz, because in harfbuzz the calls to sanitize child offsets of this table are tail calls, and so at standard optimization levels it doesn't end up growing the stack; because we call ctx.finish() after we finish with the offsets, this isn't available to us.