Bug 298908 - AbortException using generics
Summary: AbortException using generics
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Runtime (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: 1.6.8   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 301773 314984 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-01-05 17:34 EST by Flavio Donze CLA
Modified: 2010-05-29 17:54 EDT (History)
5 users (show)

See Also:


Attachments
Console output (158.42 KB, text/plain)
2010-01-05 17:35 EST, Flavio Donze CLA
no flags Details
file output (504.26 KB, text/plain)
2010-01-05 17:36 EST, Flavio Donze CLA
no flags Details
example (IdentityService) (11.73 KB, text/plain)
2010-01-05 17:37 EST, Flavio Donze CLA
no flags Details
Patch for aspectjweaver.jar (21.02 KB, application/octet-stream)
2010-01-05 19:19 EST, Andrew Clement CLA
no flags Details
patch for aspectjweaver.jar (21.19 KB, application/octet-stream)
2010-01-06 16:46 EST, Andrew Clement CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Flavio Donze CLA 2010-01-05 17:34:39 EST
Build Identifier: M20090917-0800

We are using generics in our OSGi services.
After upgrading from:
org.aspectj.runtime_1.6.7.20091127083600
org.aspectj.weaver_1.6.7.20091127083600
to
org.aspectj.runtime_1.6.7.20091214160800
org.aspectj.weaver_1.6.7.20091214160800
we are getting real strange exceptions during startup of the server.
See attachments console.log and file.log.
Sometimes the server starts up fine but 5 of 4 times it fails.



Reproducible: Sometimes
Comment 1 Flavio Donze CLA 2010-01-05 17:35:24 EST
Created attachment 155384 [details]
Console output
Comment 2 Flavio Donze CLA 2010-01-05 17:36:11 EST
Created attachment 155385 [details]
file output
Comment 3 Flavio Donze CLA 2010-01-05 17:37:17 EST
Created attachment 155386 [details]
example (IdentityService)

should I add the super classes?
Comment 4 Andrew Clement CLA 2010-01-05 17:44:09 EST
actually the recursion problem is something I'm investigating just now as it was reported here:

http://forum.springsource.org/showthread.php?t=82593

Your bug is possibly a dup of bug 290137, but I won't say that until I've investigated a bit more today.
Comment 5 Andrew Clement CLA 2010-01-05 17:44:45 EST
one thing - is this new since you upgraded to 1.6.7?  What version were you using previously?
Comment 6 Flavio Donze CLA 2010-01-05 18:13:29 EST
Hi Andy

great that you are already on it!

All I did was an upgrade from build 1.6.7.20091127083600 to build 1.6.7.20091214160800.

If I downgrade back to 1.6.7.20091127083600, the server runs fine again.

I tried out the current build 1.6.7.20100105084524, same problem.

The issue reported in the spring forum seems to be the same one.

Maybe I could help providing more information (e.g. spring bean declaration..)?
Comment 7 Andrew Clement CLA 2010-01-05 19:19:41 EST
Created attachment 155389 [details]
Patch for aspectjweaver.jar

thanks for including the dates of the two versions, that is really helpful.  As this is an issue we seem to have had for a long time, but it has recently started occurring more frequently, I have a suspicion what the problem is.

I've attached a patch of class files that replaces a few in the latest AspectJ 1.6.7 builds.  If you are on a recent AspectJ, you can apply this as follows (save it in the folder where the weaver jar is)

jar -xvf worldpatch.zip
jar -uvf aspectjweaver.jar org

(Oh probably backup your aspectjweaver.jar first)

That will replace about 5 classes.  I'd be very keen to hear if it made any difference.
Comment 8 Flavio Donze CLA 2010-01-06 03:40:43 EST
I patched my 1.6.7.20100105084524 build and started my server now 10 times in a row, without exceptions!

Awesome that was quick :-)

I'll keep an eye on it and will patch my co-developers server too.
Comment 9 Andrew Clement CLA 2010-01-06 13:00:39 EST
thanks for trying that out so quickly.  My suspicion seems correct.  The patch includes something to alleviate the problem but not prevent it from ever occurring.

In 1.6.7 we are more actively discarding types in order to run with a smaller footprint.  This means we are now exercising the code that pulls types back in, whereas this code wouldn't typically run until much later (if ever) as types would only get discarded when memory became tight.  I think this is why I have trouble recreating this issue, because it relates to memory and when weak references are being cleared by a GC.  The world (where types are recorded) should never directly record generic types, it should only record raw types that will themselves point to the generic type.  It appears the code to bring types back in sometimes causes generic types to be recorded directly in the world - this causes the infinite loop because the logic is vaguely something like this

xxxx(Type ty) {
  if (ty.isGeneric()) {
    xxxx(ty.getRawType())
  }
  .. do something else ..
}

getRawType() actually goes to the world to look up the type, and if it discovers and returns a generic type then code like that will loop endlessly.

The patch merely switched back from WEAK references to SOFT references.  SOFT references are not gc'd as frequently and so it delays the problem occurring, but doesn't prevent it ever happening.
Comment 10 Andrew Clement CLA 2010-01-06 16:46:01 EST
Created attachment 155456 [details]
patch for aspectjweaver.jar

Flavio - is there anyway you could try another patch?  I've made some progress although I still can't recreate it. I've determined what could lead to the infinite loop and attempted to address it.  This patch will apply over the top of the old one, in the same way, and attempt to address the problem properly rather than reverting the weak/soft reference change.

This secondary patch is what I'd rather commit into AspectJ.
Comment 11 Flavio Donze CLA 2010-01-07 03:56:23 EST
Great that you found a better/cleaner solution!
I patched the jar with the new classes and it looks good. Started over 10 times in a row without an exception.

Maybe we could watch it for a week or two and then close this issue?
Comment 12 Andrew Clement CLA 2010-01-07 11:46:14 EST
thanks for trying that out.  The guy on the spring forum also confirmed the same fix worked for him too.  So I'll get this committed now.
Comment 13 Andrew Clement CLA 2010-01-08 19:19:32 EST
fix is in 1.6.8
Comment 14 Andrew Clement CLA 2010-02-04 11:36:48 EST
*** Bug 301773 has been marked as a duplicate of this bug. ***
Comment 15 Carlos Vara CLA 2010-02-16 07:15:23 EST
Hi,

I was hitting this bug (although with a different environment): no osgi and compile time weaving.

1.6.8 fixed it, thanks!
Comment 16 Andrew Clement CLA 2010-05-29 17:54:20 EDT
*** Bug 314984 has been marked as a duplicate of this bug. ***