Skip to content

ComputeCurrentStyle stack-overflows for translate values through CssAnyValue converter re-entry #243

Closed

Description

@sebastienros

Description

AngleSharp.Css 1.1.0 stack-overflows when computing the style of an element with a valid CSS individual transform property such as translate: 1px.

The failure reproduces with AngleSharp alone: no Jint, JavaScript, custom properties, Scalar, or variable dependency cycles are involved.

Versions

  • AngleSharp: 1.8.0
  • AngleSharp.Css: 1.1.0
  • .NET 10.0
  • Also relevant to the current source implementation unless already changed

Minimal reproduction

using AngleSharp;
using AngleSharp.Css.Dom;

var context = BrowsingContext.New(Configuration.Default.WithCss());
var document = await context.OpenAsync(request => request.Content(
    "<html><body><div style='translate: 1px'></div></body></html>"));

var element = document.QuerySelector("div")!;
var style = element.ComputeCurrentStyle();

Console.WriteLine(style.GetPropertyValue("translate"));

Project references:

<PackageReference Include="AngleSharp" Version="1.8.0" />
<PackageReference Include="AngleSharp.Css" Version="1.1.0" />

Actual behavior

The process exits with a stack overflow. The repeating native/.NET stack contains:

CssAnyValue.Compute
IdentifierValueConverter.Convert
OrValueConverter.Convert
CssAnyValue.Compute
...

A complete standalone reproduction and failure log are available from the investigation that found this issue.

Root cause

The translate property converter is shaped as an OrValueConverter combining none with AnyValueConverter. CssAnyValue.Compute avoids reparsing only when context.Converter is directly an AnyValueConverter.

When the converter is the composite OrValueConverter, Compute reparses the unchanged text through that same composite converter. The AnyValueConverter arm produces another unresolved CssAnyValue, and Compute(context) is immediately invoked again with the same composite converter, causing unbounded converter re-entry.

RotateConverter and ScaleConverter use the same converter shape and may be affected as well.

This is distinct from custom-property dependency-cycle handling such as #242. The reparsing branch predates that fix.

Expected behavior

ComputeCurrentStyle() should terminate and return the computed value for valid translate, rotate, and scale declarations. Composite converters containing an AnyValueConverter must not recursively reparse an unresolved CssAnyValue with the same converter indefinitely.

Suggested coverage

  • translate: 1px
  • valid two- and three-component translate forms
  • translate: none
  • corresponding valid rotate and scale forms
  • unresolved/invalid values retain existing error behavior
  • ordinary composite converters that resolve to concrete values continue computing normally
  • custom-property cycle coverage remains unchanged

Activity

  1. sebastienros commented on Sep 7, 2026

    @sebastienros
    ContributorAuthor

    Additional native verification confirms this is not a 1.1.0 or custom-property-cycle regression: the same standalone program also stack-overflows with AngleSharp.Css 1.0.2 (AngleSharp 1.8.0). translate: 1px, translate: 0 -50%, rotate: 45deg, and scale: 1 are all confirmed failures; translate: none, rotate: none, scale: none, and the existing custom-property cycle fallback control complete normally. Rotate and scale are therefore confirmed affected, not merely suspected, and downgrading to 1.0.2 is not a workaround.

  2. sebastienros commented on Sep 7, 2026

    @sebastienros
    ContributorAuthor

    Reproduction correction and history: add using AngleSharp.Dom; so QuerySelector resolves. The bug is present in published 1.1.0 and current devel/main; converter re-entry dates to commit 8295892 (January 2024), while individual transform converters exposed it in e050f3c (July 2026), before #242. PR #242 changed full-consumption/IsResolved behavior but did not introduce this recursion.

  3. added theissue type on Sep 7, 2026
  4. added this to the v1.1.1 milestone on Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions