Offline instrumentation throws OverlappingFileLockException on multimodule projects

1,064 views
Skip to first unread message

Christian Willman

unread,
Apr 25, 2013, 9:56:13 AM4/25/13
to jac...@googlegroups.com
Greetings,

We're trying to use JaCoCo's offline instrumentation mode to improve code coverage metrics for PowerMock-enabled projects. In general this works fine. However, we are finding that some projects have low code coverage because JaCoCo is throwing multiple OverlappingFileLockExceptions when the exec file is dumped after Surefire completes.

The issue doesn't seem to have a clear culprit. The issue doesn't seem to occur based upon any single identifiable factor (number of tests in class, execution time, PowerMock/non-PowerMock tests). But an afflicted project will always fail to cleanly dump the exec file, and always throws the same count of OverlappingFileLockExceptions.

The only thing that seems to resolve it is to run Surefire in forkMode=always, which is, of course, very slow. Interestingly the equivocal forkCount=1/reuseForks=false combo still produces this error.

I know this is going to be a bit of a pickle to resolve because our code is closed-source. I can prod into our code but likely can't post any snippets, or, at least, only very short, sanitized ones. I appreciate any help in finding the issue and perhaps a solution.

Environment:
- Surefire 2.12.1
- JUnit 4.8.3
- Maven 3.0.4
- Using JaCoCo Maven Plugin 0.6.2.201302030002

(Partial) Steps to reproduce:
- Invoke mvn clean compile jacoco:instrument test against a project with the jacoco agent as a dependency.

Relevant output, note how the exception is repeated (this can repeat 1-7 times depending on test module):
java.nio.channels.OverlappingFileLockException
at sun.nio.ch.FileChannelImpl$SharedFileLockTable.checkList(FileChannelImpl.java:1166)
at sun.nio.ch.FileChannelImpl$SharedFileLockTable.add(FileChannelImpl.java:1068)
at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:824)
at java.nio.channels.FileChannel.lock(FileChannel.java:860)
at org.jacoco.agent.rt.internal_5d10cad.output.FileOutput.openFile(FileOutput.java:69)
at org.jacoco.agent.rt.internal_5d10cad.output.FileOutput.writeExecutionData(FileOutput.java:53)
at org.jacoco.agent.rt.internal_5d10cad.Agent.shutdown(Agent.java:143)
at org.jacoco.agent.rt.internal_5d10cad.Agent$1.run(Agent.java:60)
java.nio.channels.OverlappingFileLockException
at sun.nio.ch.FileChannelImpl$SharedFileLockTable.checkList(FileChannelImpl.java:1166)
at sun.nio.ch.FileChannelImpl$SharedFileLockTable.add(FileChannelImpl.java:1068)
at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:824)
at java.nio.channels.FileChannel.lock(FileChannel.java:860)
at org.jacoco.agent.rt.internal_5d10cad.output.FileOutput.openFile(FileOutput.java:69)
at org.jacoco.agent.rt.internal_5d10cad.output.FileOutput.writeExecutionData(FileOutput.java:53)
at org.jacoco.agent.rt.internal_5d10cad.Agent.shutdown(Agent.java:143)
at org.jacoco.agent.rt.internal_5d10cad.Agent$1.run(Agent.java:60)
java.nio.channels.OverlappingFileLockException
at sun.nio.ch.FileChannelImpl$SharedFileLockTable.checkList(FileChannelImpl.java:1166)
at sun.nio.ch.FileChannelImpl$SharedFileLockTable.add(FileChannelImpl.java:1068)
at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:824)
at java.nio.channels.FileChannel.lock(FileChannel.java:860)
at org.jacoco.agent.rt.internal_5d10cad.output.FileOutput.openFile(FileOutput.java:69)
at org.jacoco.agent.rt.internal_5d10cad.output.FileOutput.writeExecutionData(FileOutput.java:53)
at org.jacoco.agent.rt.internal_5d10cad.Agent.shutdown(Agent.java:143)
at org.jacoco.agent.rt.internal_5d10cad.Agent$1.run(Agent.java:60)

Christian Willman

unread,
Apr 25, 2013, 10:27:14 AM4/25/13
to jac...@googlegroups.com
Upon further investigation, this is not necessarily unique to multimodules. Running offline instrumentation against a single module will still fail. Also forgot to mention that running JaCoCo via jacoco:preprare-agent works fine, but we're trying to circumvent on-the-fly instrumentation in some cases.

Marc Hoffmann

unread,
Apr 29, 2013, 8:20:27 AM4/29/13
to jac...@googlegroups.com
Hi,

this looks like you have multiple instances of the JaCoCo runtime in
your test VM (possible if different class loaders are used). As every
JaCoCo runtime installs a shutdown hook, multiple runtimes would result
in parallel writes to the exec file.

What are you executing with surefire? Is some kond of container
framework involved? I'm not sure about PowerMock, maybe this framework
somehow loads your classes under test (and so the JaCoCo runtime
classes) multiple times.

Best regards,
-marc
> --
> You received this message because you are subscribed to the Google
> Groups "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to jacoco+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out
> [1].
>
>
>
> Links:
> ------
> [1] https://groups.google.com/groups/opt_out

sylvain...@gmail.com

unread,
Sep 13, 2013, 4:17:39 AM9/13/13
to jac...@googlegroups.com
I also came accross this error and found the problem : http://code.google.com/p/powermock/issues/detail?id=458

The workaround is to add @PowerMockIgnore("org.jacoco.agent.rt.*") on all tests...

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages