Fix crash in OffscreenCanvas when using sibling-index() in font calc [chromium/src : main]

1 view
Skip to first unread message

zhenbang Jiang (Gerrit)

unread,
Jan 4, 2026, 2:38:19 AM (8 days ago) Jan 4
to Munira Tursunova, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org
Attention needed from Munira Tursunova

zhenbang Jiang added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
zhenbang Jiang . resolved

Hi, could you take a look at this? thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Munira Tursunova
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I6640ff6c25e1ac830e34ffaf7def51c6252da4ca
Gerrit-Change-Number: 7366009
Gerrit-PatchSet: 1
Gerrit-Owner: zhenbang Jiang <edom...@gmail.com>
Gerrit-Reviewer: Munira Tursunova <moo...@google.com>
Gerrit-Reviewer: zhenbang Jiang <edom...@gmail.com>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-Attention: Munira Tursunova <moo...@google.com>
Gerrit-Comment-Date: Sun, 04 Jan 2026 07:37:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Rune Lillesveen (Gerrit)

unread,
Jan 5, 2026, 5:20:54 AM (6 days ago) Jan 5
to zhenbang Jiang, Munira Tursunova, Rune Lillesveen, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org
Attention needed from Munira Tursunova and zhenbang Jiang

Rune Lillesveen added 1 comment

File third_party/blink/renderer/core/css/css_math_expression_node.cc
Line 5276, Patchset 1 (Latest): // In OffscreenCanvas or other contexts without DOM elements, return 0.
Rune Lillesveen . unresolved

This is not at all specified afaict from the spec.

It's not obvious to me whether the correct behavior is to disallow these functions at parse time or be handled like this.

Given the resolution to '0' for inner tree reference, I'm fine with making this 0 for now:

"A tree counting function is a tree-scoped reference where it references an implicit tree-scoped name for the element it resolves against. This is done to not leak tree information to an outer tree. A tree counting function that is scoped to an outer tree relative to the element it resolves against, will always resolve to 0."

Could you extend the comment to say that this is not covered by the spec?

Open in Gerrit

Related details

Attention is currently required from:
  • Munira Tursunova
  • zhenbang Jiang
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I6640ff6c25e1ac830e34ffaf7def51c6252da4ca
    Gerrit-Change-Number: 7366009
    Gerrit-PatchSet: 1
    Gerrit-Owner: zhenbang Jiang <edom...@gmail.com>
    Gerrit-Reviewer: Munira Tursunova <moo...@google.com>
    Gerrit-Reviewer: Rune Lillesveen <fut...@chromium.org>
    Gerrit-Reviewer: zhenbang Jiang <edom...@gmail.com>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-Attention: zhenbang Jiang <edom...@gmail.com>
    Gerrit-Attention: Munira Tursunova <moo...@google.com>
    Gerrit-Comment-Date: Mon, 05 Jan 2026 10:20:40 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    zhenbang Jiang (Gerrit)

    unread,
    Jan 6, 2026, 9:32:17 PM (5 days ago) Jan 6
    to Munira Tursunova, Rune Lillesveen, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org
    Attention needed from Munira Tursunova and Rune Lillesveen

    zhenbang Jiang added 1 comment

    File third_party/blink/renderer/core/css/css_math_expression_node.cc
    Line 5276, Patchset 1: // In OffscreenCanvas or other contexts without DOM elements, return 0.
    Rune Lillesveen . resolved

    This is not at all specified afaict from the spec.

    It's not obvious to me whether the correct behavior is to disallow these functions at parse time or be handled like this.

    Given the resolution to '0' for inner tree reference, I'm fine with making this 0 for now:

    "A tree counting function is a tree-scoped reference where it references an implicit tree-scoped name for the element it resolves against. This is done to not leak tree information to an outer tree. A tree counting function that is scoped to an outer tree relative to the element it resolves against, will always resolve to 0."

    Could you extend the comment to say that this is not covered by the spec?

    zhenbang Jiang

    Added relevant comments as discussed. Pls take another look.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Munira Tursunova
    • Rune Lillesveen
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I6640ff6c25e1ac830e34ffaf7def51c6252da4ca
      Gerrit-Change-Number: 7366009
      Gerrit-PatchSet: 2
      Gerrit-Owner: zhenbang Jiang <edom...@gmail.com>
      Gerrit-Reviewer: Munira Tursunova <moo...@google.com>
      Gerrit-Reviewer: Rune Lillesveen <fut...@chromium.org>
      Gerrit-Reviewer: zhenbang Jiang <edom...@gmail.com>
      Gerrit-CC: Menard, Alexis <alexis...@intel.com>
      Gerrit-Attention: Rune Lillesveen <fut...@chromium.org>
      Gerrit-Attention: Munira Tursunova <moo...@google.com>
      Gerrit-Comment-Date: Wed, 07 Jan 2026 02:31:45 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Rune Lillesveen <fut...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Rune Lillesveen (Gerrit)

      unread,
      Jan 7, 2026, 7:43:42 AM (4 days ago) Jan 7
      to zhenbang Jiang, Munira Tursunova, Rune Lillesveen, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org
      Attention needed from Munira Tursunova and zhenbang Jiang

      Rune Lillesveen added 1 comment

      File third_party/blink/renderer/core/css/css_math_expression_node.cc
      Line 5276, Patchset 1: // In OffscreenCanvas or other contexts without DOM elements, return 0.
      Rune Lillesveen . unresolved

      This is not at all specified afaict from the spec.

      It's not obvious to me whether the correct behavior is to disallow these functions at parse time or be handled like this.

      Given the resolution to '0' for inner tree reference, I'm fine with making this 0 for now:

      "A tree counting function is a tree-scoped reference where it references an implicit tree-scoped name for the element it resolves against. This is done to not leak tree information to an outer tree. A tree counting function that is scoped to an outer tree relative to the element it resolves against, will always resolve to 0."

      Could you extend the comment to say that this is not covered by the spec?

      zhenbang Jiang

      Added relevant comments as discussed. Pls take another look.

      Rune Lillesveen

      I forgot, but this was discussed in https://github.com/w3c/csswg-drafts/issues/10982 where the sentiment is to disallow sibling-index/count() at parse time when there is no element context:

      https://github.com/w3c/csswg-drafts/issues/10982#issuecomment-2724587029
      https://github.com/w3c/csswg-drafts/issues/10982#issuecomment-2725546630

      So, I think we should make sure these values are not allowed instead of using some default index.

      For this canvas case, it could be solved by making FontStyleResolver::ComputeFont() check that the values are not element-dependent before doing the resolution.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Munira Tursunova
      • zhenbang Jiang
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I6640ff6c25e1ac830e34ffaf7def51c6252da4ca
        Gerrit-Change-Number: 7366009
        Gerrit-PatchSet: 2
        Gerrit-Owner: zhenbang Jiang <edom...@gmail.com>
        Gerrit-Reviewer: Munira Tursunova <moo...@google.com>
        Gerrit-Reviewer: Rune Lillesveen <fut...@chromium.org>
        Gerrit-Reviewer: zhenbang Jiang <edom...@gmail.com>
        Gerrit-CC: Menard, Alexis <alexis...@intel.com>
        Gerrit-Attention: zhenbang Jiang <edom...@gmail.com>
        Gerrit-Attention: Munira Tursunova <moo...@google.com>
        Gerrit-Comment-Date: Wed, 07 Jan 2026 12:43:27 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Rune Lillesveen <fut...@chromium.org>
        Comment-In-Reply-To: zhenbang Jiang <edom...@gmail.com>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        zhenbang Jiang (Gerrit)

        unread,
        Jan 10, 2026, 11:16:04 PM (18 hours ago) Jan 10
        to Munira Tursunova, Rune Lillesveen, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org
        Attention needed from Munira Tursunova and Rune Lillesveen

        zhenbang Jiang added 1 comment

        File third_party/blink/renderer/core/css/css_math_expression_node.cc
        Line 5276, Patchset 1: // In OffscreenCanvas or other contexts without DOM elements, return 0.
        Rune Lillesveen . resolved

        This is not at all specified afaict from the spec.

        It's not obvious to me whether the correct behavior is to disallow these functions at parse time or be handled like this.

        Given the resolution to '0' for inner tree reference, I'm fine with making this 0 for now:

        "A tree counting function is a tree-scoped reference where it references an implicit tree-scoped name for the element it resolves against. This is done to not leak tree information to an outer tree. A tree counting function that is scoped to an outer tree relative to the element it resolves against, will always resolve to 0."

        Could you extend the comment to say that this is not covered by the spec?

        zhenbang Jiang

        Added relevant comments as discussed. Pls take another look.

        Rune Lillesveen

        I forgot, but this was discussed in https://github.com/w3c/csswg-drafts/issues/10982 where the sentiment is to disallow sibling-index/count() at parse time when there is no element context:

        https://github.com/w3c/csswg-drafts/issues/10982#issuecomment-2724587029
        https://github.com/w3c/csswg-drafts/issues/10982#issuecomment-2725546630

        So, I think we should make sure these values are not allowed instead of using some default index.

        For this canvas case, it could be solved by making FontStyleResolver::ComputeFont() check that the values are not element-dependent before doing the resolution.

        zhenbang Jiang

        Thanks for the reminder and guidance!
        I’ve moved the element-dependent calc validation to FontStyleResolver::ComputeFont() as suggested, aligning with CSSWG’s intent to disallow sibling-index/count() where there’s no element context.
        I also fixed the font-style edge case: the logic now handles both regular CSSPrimitiveValue and CSSFontStyleRangeValue (oblique ranges), scanning nested values to block invalid functions.
        All relevant font properties (font-size, font-stretch, font-style, font-weight) are covered, with invalid values skipped entirely.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Munira Tursunova
        • Rune Lillesveen
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I6640ff6c25e1ac830e34ffaf7def51c6252da4ca
          Gerrit-Change-Number: 7366009
          Gerrit-PatchSet: 3
          Gerrit-Owner: zhenbang Jiang <edom...@gmail.com>
          Gerrit-Reviewer: Munira Tursunova <moo...@google.com>
          Gerrit-Reviewer: Rune Lillesveen <fut...@chromium.org>
          Gerrit-Reviewer: zhenbang Jiang <edom...@gmail.com>
          Gerrit-CC: Menard, Alexis <alexis...@intel.com>
          Gerrit-Attention: Rune Lillesveen <fut...@chromium.org>
          Gerrit-Attention: Munira Tursunova <moo...@google.com>
          Gerrit-Comment-Date: Sun, 11 Jan 2026 04:15:29 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          zhenbang Jiang (Gerrit)

          unread,
          10:45 AM (7 hours ago) 10:45 AM
          to Munira Tursunova, Rune Lillesveen, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org
          Attention needed from Munira Tursunova and Rune Lillesveen

          zhenbang Jiang added 1 comment

          File third_party/blink/renderer/core/css/css_math_expression_node.cc
          Line 5276, Patchset 1: // In OffscreenCanvas or other contexts without DOM elements, return 0.
          Rune Lillesveen . unresolved

          This is not at all specified afaict from the spec.

          It's not obvious to me whether the correct behavior is to disallow these functions at parse time or be handled like this.

          Given the resolution to '0' for inner tree reference, I'm fine with making this 0 for now:

          "A tree counting function is a tree-scoped reference where it references an implicit tree-scoped name for the element it resolves against. This is done to not leak tree information to an outer tree. A tree counting function that is scoped to an outer tree relative to the element it resolves against, will always resolve to 0."

          Could you extend the comment to say that this is not covered by the spec?

          zhenbang Jiang

          Added relevant comments as discussed. Pls take another look.

          Rune Lillesveen

          I forgot, but this was discussed in https://github.com/w3c/csswg-drafts/issues/10982 where the sentiment is to disallow sibling-index/count() at parse time when there is no element context:

          https://github.com/w3c/csswg-drafts/issues/10982#issuecomment-2724587029
          https://github.com/w3c/csswg-drafts/issues/10982#issuecomment-2725546630

          So, I think we should make sure these values are not allowed instead of using some default index.

          For this canvas case, it could be solved by making FontStyleResolver::ComputeFont() check that the values are not element-dependent before doing the resolution.

          zhenbang Jiang

          Thanks for the reminder and guidance!
          I’ve moved the element-dependent calc validation to FontStyleResolver::ComputeFont() as suggested, aligning with CSSWG’s intent to disallow sibling-index/count() where there’s no element context.
          I also fixed the font-style edge case: the logic now handles both regular CSSPrimitiveValue and CSSFontStyleRangeValue (oblique ranges), scanning nested values to block invalid functions.
          All relevant font properties (font-size, font-stretch, font-style, font-weight) are covered, with invalid values skipped entirely.

          zhenbang Jiang

          Correction: I just noticed my unit tests are failing. Need to revisit this issue. Please disregard my previous comment.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Munira Tursunova
          • Rune Lillesveen
          Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Owners
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            • requirement is not satisfiedReview-Enforcement
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: I6640ff6c25e1ac830e34ffaf7def51c6252da4ca
            Gerrit-Change-Number: 7366009
            Gerrit-PatchSet: 3
            Gerrit-Owner: zhenbang Jiang <edom...@gmail.com>
            Gerrit-Reviewer: Munira Tursunova <moo...@google.com>
            Gerrit-Reviewer: Rune Lillesveen <fut...@chromium.org>
            Gerrit-Reviewer: zhenbang Jiang <edom...@gmail.com>
            Gerrit-CC: Menard, Alexis <alexis...@intel.com>
            Gerrit-Attention: Rune Lillesveen <fut...@chromium.org>
            Gerrit-Attention: Munira Tursunova <moo...@google.com>
            Gerrit-Comment-Date: Sun, 11 Jan 2026 15:45:22 +0000
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            zhenbang Jiang (Gerrit)

            unread,
            10:51 AM (6 hours ago) 10:51 AM
            to Munira Tursunova, Rune Lillesveen, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org
            Attention needed from Munira Tursunova and Rune Lillesveen

            zhenbang Jiang added 1 comment

            File third_party/blink/renderer/core/css/css_math_expression_node.cc
            Line 5276, Patchset 1: // In OffscreenCanvas or other contexts without DOM elements, return 0.
            Rune Lillesveen . resolved

            This is not at all specified afaict from the spec.

            It's not obvious to me whether the correct behavior is to disallow these functions at parse time or be handled like this.

            Given the resolution to '0' for inner tree reference, I'm fine with making this 0 for now:

            "A tree counting function is a tree-scoped reference where it references an implicit tree-scoped name for the element it resolves against. This is done to not leak tree information to an outer tree. A tree counting function that is scoped to an outer tree relative to the element it resolves against, will always resolve to 0."

            Could you extend the comment to say that this is not covered by the spec?

            zhenbang Jiang

            Added relevant comments as discussed. Pls take another look.

            Rune Lillesveen

            I forgot, but this was discussed in https://github.com/w3c/csswg-drafts/issues/10982 where the sentiment is to disallow sibling-index/count() at parse time when there is no element context:

            https://github.com/w3c/csswg-drafts/issues/10982#issuecomment-2724587029
            https://github.com/w3c/csswg-drafts/issues/10982#issuecomment-2725546630

            So, I think we should make sure these values are not allowed instead of using some default index.

            For this canvas case, it could be solved by making FontStyleResolver::ComputeFont() check that the values are not element-dependent before doing the resolution.

            zhenbang Jiang

            Thanks for the reminder and guidance!
            I’ve moved the element-dependent calc validation to FontStyleResolver::ComputeFont() as suggested, aligning with CSSWG’s intent to disallow sibling-index/count() where there’s no element context.
            I also fixed the font-style edge case: the logic now handles both regular CSSPrimitiveValue and CSSFontStyleRangeValue (oblique ranges), scanning nested values to block invalid functions.
            All relevant font properties (font-size, font-stretch, font-style, font-weight) are covered, with invalid values skipped entirely.

            zhenbang Jiang

            Correction: I just noticed my unit tests are failing. Need to revisit this issue. Please disregard my previous comment.

            zhenbang Jiang

            Marked as resolved.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Munira Tursunova
            • Rune Lillesveen
            Submit Requirements:
              • requirement satisfiedCode-Coverage
              • requirement is not satisfiedCode-Owners
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedReview-Enforcement
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: chromium/src
              Gerrit-Branch: main
              Gerrit-Change-Id: I6640ff6c25e1ac830e34ffaf7def51c6252da4ca
              Gerrit-Change-Number: 7366009
              Gerrit-PatchSet: 3
              Gerrit-Owner: zhenbang Jiang <edom...@gmail.com>
              Gerrit-Reviewer: Munira Tursunova <moo...@google.com>
              Gerrit-Reviewer: Rune Lillesveen <fut...@chromium.org>
              Gerrit-Reviewer: zhenbang Jiang <edom...@gmail.com>
              Gerrit-CC: Menard, Alexis <alexis...@intel.com>
              Gerrit-Attention: Rune Lillesveen <fut...@chromium.org>
              Gerrit-Attention: Munira Tursunova <moo...@google.com>
              Gerrit-Comment-Date: Sun, 11 Jan 2026 15:50:57 +0000
              satisfied_requirement
              unsatisfied_requirement
              open
              diffy
              Reply all
              Reply to author
              Forward
              0 new messages