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

Infinite loop in Resolver #2119

Closed
bwilkerson opened this issue Mar 12, 2012 · 2 comments
Closed

Infinite loop in Resolver #2119

bwilkerson opened this issue Mar 12, 2012 · 2 comments

Comments

@bwilkerson
Copy link
Member

The method Resolver.hasRedirectedConstructorCycle(ConstructorElement) contains a loop that will never terminate when there are cyclic references in constructor invocations. This was caught by .../dart/frog/tests/leg_only/src/CyclicConstructorTest.dart.

In this particular case, "next" oscillates between being the element for the constructor named "a" and the constructor named "b".

@bwilkerson
Copy link
Member Author

I have a proposed fix for this bug. Replace the method with the following:

  private boolean hasRedirectedConstructorCycle(ConstructorElement constructorElement) {
    HashSet<ConstructorElement> visited = new HashSet<ConstructorElement>();
    ConstructorElement next = getNextConstructorInvocation(constructorElement);
    while (next != null) {
      if (visited.contains(next)) {
        return true;
      }
      if (constructorElement.getName().equals(next.getName())) {
        return true;
      }
      visited.add(next);
      next = getNextConstructorInvocation(next);
    }
    return false;
  }

It's difficult for me to run the dartc tests and I'm not certain that this is the right fix, so I'll leave it to you to evaluate it. I believe that it fixes this particular issue, but there appear to be other issues with opening frog. Continuing to investigate the larger issue.

@DartBot
Copy link

DartBot commented Mar 14, 2012

This comment was originally written by zundel@google.com


Now that's the kind of bug report I like! (one with a patch in it)
r5447


Added Fixed label.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants