Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Circular reference in series.data causes stack overflow thus chart fails to show #19703

Open
li6in9muyou opened this issue Mar 11, 2024 · 0 comments
Labels
bug en This issue is in English pending We are not sure about whether this is a bug/new feature.

Comments

@li6in9muyou
Copy link

Version

5.5.0

Link to Minimal Reproduction

https://echarts.apache.org/examples/zh/editor.html?c=sunburst-simple&code=MYewdgzgLgBATiEsC8MDeAoGNgAsCWANgCZwCmYAXDANoC6GAvgNwaiSwCGMqm2ADp3Jgo1BEiatxUAHR4ipCjP4BXCLgAUnAJSsMIflHzge6LDAhk4-MhGp9sMKAE9-ZagHIIKsACMVcNAeADTm2MScUJzUNNIM2IySQA

Steps to Reproduce

  1. paste the follow code in to echarts official example editor
  2. open dev tool, read latest exception
const root = {
  name: "root",
  value: 20,
  children: []
};
const a = {
  name: "a",
  value: 10,
  parent: root
};
root.children.push(a);

option = {
  series: {
    type: 'sunburst',
    data: [root]
  }
};

Current Behavior

In step 2, a RangeError: Maximum call stack size exceeded is thrown and the chart is not displayed.

Expected Behavior

Chart is displayed properly.

Environment

- OS: Win 10
- Browser: Chrome 122.0.6261.112
- Framework: vanillajs

Any additional comments?

This issues is repeated in zrender issue 1066. This stack overflow is caused by a clone utility that does not guard against circular reference. And this clone process is initiated by OptionManager here. According to comments, cloneing here serves the purpose of avoiding modifying the user supplied option argument. In that regard, I suppose it's more robust to guard against circular references when cloneing.

Circular reference is perfectly valid and reasonable in many cases. For example, series-sunburst accepts tree-like series.data and a user may store a parent link in every tree node so that click handlers on this chart can construct a path from node to tree root easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug en This issue is in English pending We are not sure about whether this is a bug/new feature.
Projects
None yet
Development

No branches or pull requests

1 participant