Bug 573440 - The shadowId of Shadow may not be unique.
Summary: The shadowId of Shadow may not be unique.
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.9.5   Edit
Hardware: PC Windows 10
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-08 10:51 EDT by Xiyou Ye CLA
Modified: 2021-05-14 18:06 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xiyou Ye CLA 2021-05-08 10:51:13 EDT
The source code of Shadow.class has pointed out that it may be a bug:

------

public abstract class Shadow {

	// every Shadow has a unique id, doesn't matter if it wraps...
	private static int nextShadowID = 100; // easier to spot than zero. // OPTIMIZE is this a bug? static?
        //....
}

------

It's quite easy to find that this code has problems in concurrency.

One more step, maybe I'm the victim of this bug?

I just built an application with Spring AOP which uses AspectJ. Randomly, the pointcut didn't work. Once happended, I have to restart the application, praying it can work, due to those caches in every layers.

I spent several hours to confirm whether the interceptor was applied correctly. Interestingly, for the same class, sometimes it is correct and sometimes it is wrong. I was stuck on this piece of code:

---

public final FuzzyBoolean match(Shadow shadow) {
		if (shadow.shadowId == lastMatchedShadowId) {
			return lastMatchedShadowResult;
		}
                //...
}

---

For some reason I couldn't know the last matched shadow. This makes the problem more complicated.

So here's my dilemma. I don't know what happened before it entered, so I can’t confirm whether the last match was itself. I found another bug, but I'm not sure if this bug may cause the confusing behavior.
Comment 1 Andrew Clement CLA 2021-05-14 18:06:29 EDT
So, you did confirm the problem was with the nextShadowId field treatment?

If you had a test project that demonstrated the issue, it would be much easier to get into (and I could potentially add a test case based on such a project).