Bug 333572 - NegativeArraySizeException
Summary: NegativeArraySizeException
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.6.11   Edit
Hardware: PC Windows XP
: P3 major with 7 votes (vote)
Target Milestone: 1.6.11   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-05 10:00 EST by Ünhan Inay CLA
Modified: 2011-02-21 00:23 EST (History)
2 users (show)

See Also:


Attachments
Error log from Helios SR 1 (13.75 KB, text/plain)
2011-01-17 12:32 EST, Ünhan Inay CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ünhan Inay CLA 2011-01-05 10:00:23 EST
Build Identifier: 

java.lang.NegativeArraySizeException
at org.aspectj.util.FileUtil.readStringArray(FileUtil.java:1070)
at org.aspectj.weaver.patterns.WildTypePattern.readTypePattern150(WildTypePattern.java:1359)
at org.aspectj.weaver.patterns.WildTypePattern.read(WildTypePattern.java:1338)
at org.aspectj.weaver.patterns.TypePattern.read(TypePattern.java:308)
at org.aspectj.weaver.patterns.WildAnnotationTypePattern.read(WildAnnotationTypePattern.java:331 ... Job.run(AutoBuildJob.java:242)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

Compile error: NegativeArraySizeException thrown: null

Reproducible: Sometimes
Comment 1 Andrew Clement CLA 2011-01-07 18:02:48 EST
Are you doing a straightforward compile all from source, or are you binary weaving?  Can you give me an idea of the kinds of pointcut you are using?
Comment 2 Ünhan Inay CLA 2011-01-10 03:27:58 EST
(In reply to comment #1)
> Are you doing a straightforward compile all from source, or are you binary
> weaving?  Can you give me an idea of the kinds of pointcut you are using?

Yes, it is a straightforward compile all from source. We're using SpringSource ToolSuite >= 2.5 in conjunction with Java 1.6.0_22, JAX WS (Metro) 2.1.7 and Maven 3.0.1, etc.
Comment 3 Ünhan Inay CLA 2011-01-17 12:32:14 EST
Created attachment 186927 [details]
Error log from Helios SR 1
Comment 4 Ünhan Inay CLA 2011-01-17 12:40:17 EST
I can reproduce now this kind of error every time i synchronize first at all and afterwards want update incoming sources Eclipse want to build the workspace. 'Build automatically' is active. For reproducing this i have picked Eclipse 3.6 and STS 2.5.2 and all the plugins we are using an completed our kind of IDE. 

It was interesting to see, that the system is searching for some xml files that can't be found. The prefix is null! Please refer to the attachment.

I think the error log can help to limit this problem maybe.
Comment 5 Ünhan Inay CLA 2011-01-20 15:39:31 EST
Even I get rid of 3rd party checkstyle-plugin Eclipse is throwing NegativeArrayException some times.
Comment 6 Ünhan Inay CLA 2011-01-20 15:44:43 EST
(In reply to comment #1)
> Are you doing a straightforward compile all from source, or are you binary
> weaving?  Can you give me an idea of the kinds of pointcut you are using?

Hi Andy,

as far as i know it was straightforward compile but the last time i've discovered that AspectJ is doing compile time weaving. This seems like binary weaving. As you need a hint which kind of pointcuts are concerned I've discovered today that there are execution pointcuts on methods. One aspect in our application is to trace all exceptions which are thrown by our application. I hope this would be helpful to you

Best regards
Ünhan
Comment 7 Ünhan Inay CLA 2011-01-21 05:01:10 EST
(In reply to comment #6)
> (In reply to comment #1)
> > Are you doing a straightforward compile all from source, or are you binary
> > weaving?  Can you give me an idea of the kinds of pointcut you are using?
> 
> Hi Andy,
> 
> as far as i know it was straightforward compile but the last time i've
> discovered that AspectJ is doing compile time weaving. This seems like binary
> weaving. As you need a hint which kind of pointcuts are concerned I've
> discovered today that there are execution pointcuts on methods. One aspect in
> our application is to trace all exceptions which are thrown by our application.
> I hope this would be helpful to you
> 
> Best regards
> Ünhan

The other aspect concern validation of public method and constructor parameter calls.
Comment 8 Andrew Clement CLA 2011-01-21 12:09:09 EST
Is there any way you can share some code with me? (can be privately, doesn't have to be through bugzilla) - I really want to fix this but if I can't recreate it then I'll have serious difficulty determining the cause.  It is related to the serialized form of the aspect, but I would need to see the full text of the pointcuts involved in order to determine the problem.
Comment 9 Ünhan Inay CLA 2011-01-24 11:30:31 EST
(In reply to comment #8)
> Is there any way you can share some code with me? (can be privately, doesn't
> have to be through bugzilla) - I really want to fix this but if I can't
> recreate it then I'll have serious difficulty determining the cause.  It is
> related to the serialized form of the aspect, but I would need to see the full
> text of the pointcuts involved in order to determine the problem.

Hello Andy,

this would be a great help. We appreciate this offer and i understand you from developers point of view. Therefore i want to send you 2 aspects in hope that we can fix this. Additionally i want to mention that not only XP is concerned, even Windows 7 systems are concerned with this kind of bug.

I'll send you an email. Should i send this 2 your gmail account?

Kindly regards
Ünhan
Comment 10 Andrew Clement CLA 2011-01-24 15:09:48 EST
gmail account is fine, thanks!
Comment 11 Ünhan Inay CLA 2011-01-25 11:04:10 EST
Done ,-) Not 4 all
Comment 12 Andrew Clement CLA 2011-01-25 14:34:08 EST
I have the sources now and the patterns of interest are like this:

execution(*.new(.., @foo.bar.* (*), ..))

The interesting bit of the stack trace, pulled from the log is:


ava.lang.NegativeArraySizeException
	at org.aspectj.util.FileUtil.readStringArray(FileUtil.java:1070)
	at org.aspectj.weaver.patterns.WildTypePattern.readTypePattern150(WildTypePattern.java:1359)
	at org.aspectj.weaver.patterns.WildTypePattern.read(WildTypePattern.java:1338)
	at org.aspectj.weaver.patterns.TypePattern.read(TypePattern.java:308)
	at org.aspectj.weaver.patterns.WildAnnotationTypePattern.read(WildAnnotationTypePattern.java:331)
	at org.aspectj.weaver.patterns.AnnotationTypePattern.read(AnnotationTypePattern.java:91)
	at org.aspectj.weaver.patterns.AnyWithAnnotationTypePattern.read(AnyWithAnnotationTypePattern.java:100)
	at org.aspectj.weaver.patterns.TypePattern.read(TypePattern.java:326)
	at org.aspectj.weaver.patterns.TypePatternList.read(TypePatternList.java:492)
	at org.aspectj.weaver.patterns.SignaturePattern.read(SignaturePattern.java:912)
	at org.aspectj.weaver.patterns.KindedPointcut.read(KindedPointcut.java:335)

So we can see it is reading a signature pattern when things go wrong and from the line number it is reading the type pattern list for the parameters in the pointcut.  The 'AnyWithAnnotationTypePattern' suggests it is reading the middle parameter: '@foo.bar.* (*)'.

It seems sheer fluke that, given all the kinds of data that are being written out (bytes/strings/booleans/etc) the point when it reads the incorrect data from the stream just happens to be looking for the type of object that is there.  An integer.  The string arrays that area written out are preceeded by their length - 0 if there are no entries.  The crash occurs because when reading the array back in we read a -1.

What is interesting is that just before the string array in the stream is a type pattern list for any relevant type parameters.  of course there are 0 of those in this case.  However, a recent change (in 1.6.9) was whether the serialized form of a type pattern list included a source location.  Up to 1.6.9 it did, after 1.6.9 it did not.  The first entry in a serialized source location is the start position - and for a situation where there are 0 type parameters, the start position will be -1...  Could that be the -1 being read?

The question then might be, how did the -1 get into the output stream if 1.6.9 or later won't be writing it out.
Comment 13 Andrew Clement CLA 2011-02-03 12:01:44 EST
Under bug 335682 I might have solved this, please grab an AJDT dev build: http://download.eclipse.org/tools/ajdt/36/dev/update
Comment 14 Ünhan Inay CLA 2011-02-04 09:19:42 EST
Hi Andy,

I'll verify this until Monday
Until now it seems good ,-)

Thank u
Ünhan
Comment 15 Ünhan Inay CLA 2011-02-09 11:48:56 EST
(In reply to comment #14)
> Hi Andy,
> 
> I'll verify this until Monday
> Until now it seems good ,-)
> 
> Thank u
> Ünhan

No problems registered since i've updated *THUMS_UP*
Comment 16 Andrew Clement CLA 2011-02-21 00:23:01 EST
thanks for confirming the fix