Skip to content

Tokens that refer to each other can grow without limit and freeze StableBar while loading #675

Closed

Description

@M4n0x

What happens

@token. and @setting. references are expanded with no limit on how much they produce. StableBar catches a reference that points back at itself, but not one that grows: when each token refers to the next one twice, the expanded value doubles at every level. A configuration, theme or package of a few lines can then produce millions of values, and StableBar freezes while it loads.

Steps to reproduce

  1. In a scratch configuration, add tokens where each level refers to the one below twice:

    "tokens": {
      "t0": "#ffffff",
      "t1": ["@token.t0", "@token.t0"],
      "t2": ["@token.t1", "@token.t1"],
      "…": "and so on up to t40",
      "t40": ["@token.t39", "@token.t39"]
    }
  2. Use @token.t40 anywhere, and load the file (StableBar --validate <file>, or open it with --config).

Expected

Loading stops with a clear error that names the reference being expanded, the same way an unknown reference or a cycle does. Ordinary themes, packages and configurations load exactly as before.

Environment

main at 8196fd9 (v0.16.0-beta.20261115111438.1100).

Diagnosis

substituteConfigurationReferences in Sources/StableBar/ThemeConfiguration.swift recurses through objects and arrays and replaces each reference with its fully expanded value. It tracks the path to detect cycles, but nothing counts what it produces.

Proposal

  • Count the values produced while expanding references, and fail loading once the count passes 100,000, far above any real theme or configuration.
  • Report it through the existing configuration errors, with the reference name.
  • Tests: the doubling chain above fails quickly with that error; the bundled themes and examples still load.

This matters more for anything that loads a theme without a click, such as a link that previews a theme (#676): opening it must never freeze StableBar.

Related

  • Cycles are already caught (referenceCycle); this adds a size limit next to it.

Triaged by Claude Code (Claude Opus 5.5).

Activity

  1. added
    bug
    on Nov 15, 2026
  2. stablebar-releases commented on Nov 16, 2026

    @stablebar-releases

    🎉 This issue has been resolved in version 0.16.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugreleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions