-
Notifications
You must be signed in to change notification settings - Fork 381
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
Polyglot Notebook: Stack overflow when creating instance of class with recursive IEnumerable #3625
Comments
Can someone take a look or provide some insight? The class definition is below. It runs fine. But if I create an instance in polyglot notebook, the kernel crashes due to stack overflow. There is no infinite-loop in the code, just recursive call on the child nodes (which is empty). It seems that the .net interactive or polyglot causes infinite-loop somewhere. public class TestIEnumerator : IEnumerable<TestIEnumerator>
{
private List<TestIEnumerator> children;
public List<TestIEnumerator> Children
{
get
{
if (children==null) children = new List<TestIEnumerator>();
return children;
}
}
public IEnumerator<TestIEnumerator> GetEnumerator()
{
List<TestIEnumerator> childList = new List<TestIEnumerator>();
recurseChildren(this, ref childList, 0);
return childList.GetEnumerator();
}
private void recurseChildren(TestIEnumerator f, ref List<TestIEnumerator>coll, int lvl)
{
coll.Add(f);
Console.WriteLine("RecurseChildren level: " + lvl);
foreach(TestIEnumerator tmp in f.Children)
{
RecurseChildren(tmp, ref coll, lvl+1);
}
}
System.Collection.IEnumerator System.Collection.IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
} |
duyang76
changed the title
Stack overflow when creating instance of class with recursive IEnumerable
Polyglot Notebook: Stack overflow when creating instance of class with recursive IEnumerable
Sep 11, 2024
Can someone provide some thoughts? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can replicate this issue with a bare minimum example: a class implementing IEnumerable of itself with an empty child list.
Version: 1.0.522904
I cannot post from my company's internal network, so I'm typing from my phone and taking a screenshot below. But it is pretty obvious.
The text was updated successfully, but these errors were encountered: