Bug 319315 - internal compiler error with AjcXmlTask (parallel testing)
Summary: internal compiler error with AjcXmlTask (parallel testing)
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-08 16:22 EDT by Oliver CLA
Modified: 2013-06-24 11:04 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 Oliver CLA 2010-07-08 16:22:41 EDT
Build Identifier: 1.6.9.20100629172100

I have a class derived from AjcXmlTask:

public class AjcXml extends AjcXmlTask {
   ...
}

I have also some JUnit tests which uses this class to compile a test file. When I upgrade from AspectJ 1.6.5 to AspectJ 1.6.9 I got an "internal compiler error" only during the nightly build. During normal testing with Eclipse all seems to be ok but I think the nightly tests are run in parallel. Here is the stacktrace from the log file during a local test run with Maven:

Internal compiler error
java.util.EmptyStackException
	at java.util.Stack.peek(Stack.java:85)
	at java.util.Stack.pop(Stack.java:67)
	at org.aspectj.bridge.context.CompilationAndWeavingContext.leavingPhase(CompilationAndWeavingContext.java:166)
	at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.collectAllITDsAndDeclares(AjLookupEnvironment.java:377)
	at org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.completeTypeBindings(AjLookupEnvironment.java:202)
	at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:616)
	at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:357)
	at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:371)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:1022)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performBuild(AjBuildManager.java:268)
	at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:181)
	at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:112)
	at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
	at org.aspectj.tools.ajc.Main.run(Main.java:363)
	at org.aspectj.tools.ajc.Main.runMain(Main.java:240)
	at org.aspectj.tools.ant.taskdefs.AjcTask.executeInSameVM(AjcTask.java:1236)
	at org.aspectj.tools.ant.taskdefs.AjcTask.execute(AjcTask.java:1046)
	at patterntesting.tool.aspectj.AjcXmlTask.execute(AjcXmlTask.java:279)
        ...

Sometimes the stack trace starts with a ConcurrentModificationException so it looks for me a multi-threading problems which seems to be introduced after 1.6.5


Reproducible: Sometimes
Comment 1 Andrew Clement CLA 2010-07-08 17:03:55 EDT
Normally in environments where multiple-threads are going to run through that code, this method has to be called explicitly:

CompilationAndWeavingContext.setMultiThreaded(true);

it seems like you are attempting to run the compiler multi-threaded without having called that method.  (AJDT calls this method).  The main entry point to the compiler, 'Main' actively turns this OFF to get faster performance.

What is AjcXmlTask? I don't seem to have that in AspectJ.  

Becase AjcTask (if that is what you mean?) calls Main to run the compilation the flag is going to constantly get forced off.  Can you fork the VM to avoid this problem?  The alternative will be a sys prop you can set (or maybe a task property) to allow it to run multiple compiles in one vm.
Comment 2 Oliver CLA 2010-07-09 03:51:58 EDT
Yes, you are correct - it is the AjcTask where AjcXml is derived.

The tests are started using Mavens surefire plugin which is configured as

          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.5</version>
	  <configuration>
              <!-- legal values: classes, methods or both -->
	      <parallel>methods</parallel>
	      <threadCount>2</threadCount>
	  </configuration>

I can switch the parallel tests off (it works then). But I want to find multi-threading problems in our software.

If I understand you correct calling 

    CompilationAndWeavingContext.setMultiThreaded(true)

has no effect because the AjcTask would switch it off again (I checked it and got still the same problem). Can't you use the default here in the AjcTask or is it really necessary to switch it off?

Otherwise I need a chance to set it true - via sys prop, taks prop, API call or whatever.
Comment 3 Andrew Clement CLA 2010-08-26 11:29:18 EDT
Just commmitted support for this system property:

aspectj.multithreaded=true

If that is set then multi-threading will be turned on.  This is the quickest thing I could add.  It will be in a dev build later today.
Comment 4 Andrew Clement CLA 2013-06-24 11:04:42 EDT
unsetting the target field which is currently set for something already released