Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] bug in pointcut matching/cflow?

Hi Andy,

Thanks a lot -- I don't know why I didn't see your previous reply, sorry for the noise.

I see from the bug report page that you "adjusted pointcut sorting order to make cflow ahead of
if." 
Couldn't this allow for the "dual bug", where the infinite regression would be avoided by the if but is triggered by cflow? (I haven't tried myself, but maybe you thought about this already?)

-- Éric


On Jun 7, 2010, at 10:54 AM, Andy Clement wrote:

> As I wrote on 3rd June to the mailing list, I've already raised it and fixed it:
> 
> ====
> That is a dark corner isn't it, I would never recommend writing
> something like that.
> 
> Anyway, with the extra clause '&& !(execution(* *.condition()))' you
> are statically excluding the method-execution of condition().  Without
> that we have to dynamically work out that it is excluded.  Currently
> you hit the infinite loop before it can return 'no, this isn't a
> match'.  This happens because when the pointcut is rewritten in a
> normal form, the if() is considered cheaper than the cflow() and so
> its runtime check is inserted first.  Because of this we recurse into
> the if() over and over before just asking the cflow and determining it
> isn't a match.
> 
> I've raised and fixed this under
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=315651
> 
> Andy
> ====
> 
> On 7 June 2010 07:42, Eric Tanter <etanter@xxxxxxxxxxxxx> wrote:
>> Hi,
>> 
>> I haven't received any news on this since last week. I appreciate any feedback you may have (is this really a bug? am I misunderstanding something?).
>> 
>> Thanks,
>> 
>> -- Éric
>> 
>> 
>> On Jun 1, 2010, at 2:18 PM, Eric Tanter wrote:
>> 
>>> [just forwarding to aspectj-dev in case it's more appropriate here]
>>> 
>>> 
>>> Begin forwarded message:
>>> 
>>>> From: Eric Tanter <etanter@xxxxxxxxxxxxx>
>>>> Date: May 31, 2010 12:24:41 PM GMT-04:00
>>>> To: aspectj-users@xxxxxxxxxxx
>>>> Subject: [aspectj-users] bug in pointcut matching/cflow?
>>>> Reply-To: aspectj-users@xxxxxxxxxxx
>>>> 
>>>> Hi,
>>>> 
>>>> From the semantics of AspectJ, it is given that cflow(pc()) *always* matches whenever pc() matches.
>>>> 
>>>> While exploring some dark corners, we stumbled across a case where this is however _not_ the case.
>>>> 
>>>> It has a strong feel of being a bug, but maybe not, so please let us know.
>>>> 
>>>> The code below shows that the program with the scope() pointcut defined as:
>>>> if(condition()) && !cflow(execution(* *.condition()));
>>>> 
>>>> enters an infinite loop, while adding the condition
>>>> && !(execution(* *.condition()))
>>>> 
>>>> does not loop anymore (ie. works fine).
>>>> 
>>>> So this is a case where
>>>> !cflow(pc()) && !pc() is _not_ equivalent to !cflow(pc())
>>>> 
>>>> (and according to the semantics, it should be:
>>>> !cflow(pc()) && !pc()
>>>> =
>>>> !(cflow(pc()) || pc())
>>>> where the || pc() part is clearly redundant
>>>> 
>>>> Some additional notes:
>>>> - this does not have anything to do, it seems, with the fact that lexical join points in if pcds are hidden (we are talking about execution pcds in the code, not calls)
>>>> - moving the condition() method outside of the aspect does not change what we observe.
>>>> 
>>>> Can you confirm if this is a bug, or are we missing something??
>>>> 
>>>> Thanks,
>>>> 
>>>> -- Éric
>>>> 
>>>> package test;
>>>> public aspect Profiling {
>>>>      pointcut profile(): execution(* *.*(..)) ;
>>>> 
>>>>      private pointcut scope() :
>>>>                      if(condition())
>>>>                      //&& !(execution(* *.condition())) <- uncomment and infinite loop disappears
>>>>                      && !cflow(execution(* *.condition()));
>>>> 
>>>>      public static boolean condition(){
>>>>              return (Math.random()<2); //always true
>>>>      }
>>>>      before(): profile() && scope() {
>>>>              System.out.println("Entering method "+thisJoinPointStaticPart.getSignature());
>>>>      }
>>>> }
>>>> 
>>>> package test;
>>>> public class Main {
>>>> 
>>>>      private static int plus(int first, int second){
>>>>              return first + second;
>>>>      }
>>>>      public static void main(String[] args) {
>>>>              int num = plus(42,13);
>>>>              System.out.println(num);
>>>>      }
>>>> }
>>>> 
>>>> 
>>>> _______________________________________________
>>>> aspectj-users mailing list
>>>> aspectj-users@xxxxxxxxxxx
>>>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>> 
>>> _______________________________________________
>>> aspectj-dev mailing list
>>> aspectj-dev@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>> 
>> _______________________________________________
>> aspectj-dev mailing list
>> aspectj-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>> 
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev



Back to the top