Skip to content

[sanitize] Implement max offset depth - #2022

Open
cmyr wants to merge 6 commits into
sanitize-v3-real-tables-on-unifiedfrom
sanitize-recursion-check
Open

[sanitize] Implement max offset depth#2022
cmyr wants to merge 6 commits into
sanitize-v3-real-tables-on-unifiedfrom
sanitize-recursion-check

Conversation

@cmyr

@cmyr cmyr commented Aug 7, 2026

Copy link
Copy Markdown
Member

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 and others added 5 commits August 7, 2026 05:15
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.
@behdad

behdad commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

We fixed this last week in HarfBuzz: harfbuzz/harfbuzz#6116

@cmyr
cmyr force-pushed the sanitize-recursion-check branch from 374cb0e to a7a15b1 Compare August 8, 2026 18:14
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
cmyr force-pushed the sanitize-recursion-check branch from a7a15b1 to 628752d Compare August 12, 2026 19:00
@cmyr
cmyr force-pushed the sanitize-v3-real-tables-on-unified branch from d21fae0 to 7f490ca Compare August 13, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants