Bug 53766 - stack overflow with cflow(cflow(...))
Summary: stack overflow with cflow(cflow(...))
Status: RESOLVED INVALID
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.2.1   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-04 11:41 EST by Jeffrey Palm CLA
Modified: 2004-10-21 04:33 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Palm CLA 2004-03-04 11:41:56 EST
I don't know if this is a bug, but cflow(cflow(...)) causes a stack overflow
exception; here's the code:

public class CflowCflow {
  public static void main(String[] args) { new C().f(); }
  static class C { public void f() {} }
  static aspect A {
    before(): cflow(cflow(execution(* C.f()))) {}
  }
}
Comment 1 Andrew Clement CLA 2004-08-09 08:39:42 EDT
This is actually the classic case of a program containing advice that advises
itself.  This simpler variant also fails:

public class CflowCflow {
  public static void main(String[] args) { new C().f(); }
  static class C { public void f() {} }
  static aspect A {
    before(): cflow(execution(* C.f())) {}
  }
}

In order to implement Cflow, we advise all places that *might* be in the cflow.
   This will include the code for the aspect too.  So all the code in the aspect
class file gets advised (the advice itself, the initialization logic, the static
initialization logic).  In calling advice we try to get hold of an instance of
A() on which to call it.  As the constructor of A() is advised, then when
running the constructor we try and get an instance of A() on which to call it -
etc,etc until we blow the stack limit.

In order to get the above to work, I would put:

public class CflowCflow {
  public static void main(String[] args) { new C().f(); }
  static class C { public void f() {} }
  static aspect A {
    before(): cflow(execution(* C.f())) && !within(A) {}
  }
}

And to get the double cflow case to work (yuck!):

public class CflowCflow {
  public static void main(String[] args) { new C().f(); }
  static class C { public void f() {} }
  static aspect A {
    before(): cflow(cflow(execution(* C.f())) && !within(A)) && !within(A) {}
  }
}
Comment 2 Adrian Colyer CLA 2004-10-21 04:33:08 EDT
Fix released as part of AspectJ 1.2.1