jacoco / eclemma

:warning: OLD EclEmma repository, new is located at https://github.com/eclipse/eclemma
Other
81 stars 36 forks source link

Deadlock with JMockit #9

Closed scooper4711 closed 11 years ago

scooper4711 commented 12 years ago

After upgrading to Mountain Lion (10.8) I'm unable to use EclEmma. This issue effects both Eclipse Indigo and Juno (4.2). What happens is I launch e.g. a junit test and the junit view never updates with a count of unit tests or pass/fail. The process continues running, but there is no thread actually running any unit tests.

The unit tests work just fine outside of EclEmma.

marchof commented 12 years ago

Can you please help to find where is blocks? What I need is a stack dump of the blocking process. Please open the console and enter

jps

identify the process (probably with a main class like "JUnitRunner"). Then enter

jstack <pid>

Please post the result here. Thanks!

scooper4711 commented 12 years ago

The jstack command just hangs. Which is interesting in and of itself. A kill -3 gives the following output:

2012-09-27 12:34:58
Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.4-b02-402 mixed mode):

"Attach Listener" daemon prio=9 tid=7fd6d20be800 nid=0x11a25b000 in Object.wait() [11a257000]
   java.lang.Thread.State: RUNNABLE
    at sun.misc.Unsafe.ensureClassInitialized(Native Method)
    at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
    at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
    at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
    at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
    at java.lang.reflect.Field.set(Field.java:657)
    at org.jacoco.agent.rt_3vqbej.core.runtime.AbstractRuntime.disconnect(AbstractRuntime.java:90)
    at org.jacoco.agent.rt_3vqbej.CoverageTransformer.transform(CoverageTransformer.java:90)
    at sun.instrument.TransformerManager.transform(TransformerManager.java:169)
    at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:365)
    at sun.instrument.InstrumentationImpl.redefineClasses0(Native Method)
    at sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:150)
    at mockit.internal.startup.Startup.redefineMethods(Startup.java:124)
    at mockit.internal.startup.Startup.redefineMethods(Startup.java:118)
    at mockit.internal.annotations.MockClassSetup.applyClassModifications(MockClassSetup.java:162)
    at mockit.internal.annotations.MockClassSetup.redefineMethodsInClassHierarchy(MockClassSetup.java:128)
    at mockit.internal.annotations.MockClassSetup.redefineMethods(MockClassSetup.java:117)
    at mockit.internal.annotations.MockClassSetup.setUpStartupMock(MockClassSetup.java:111)
    at mockit.internal.startup.JMockitInitialization.setUpInternalStartupMock(JMockitInitialization.java:56)
    at mockit.internal.startup.JMockitInitialization.loadInternalStartupMocksForJUnitIntegration(JMockitInitialization.java:48)
    at mockit.internal.startup.JMockitInitialization.initialize(JMockitInitialization.java:26)
    at mockit.internal.startup.Startup.initialize(Startup.java:68)
    at mockit.internal.startup.Startup.agentmain(Startup.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
    at sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:348)

"ReaderThread" prio=5 tid=7fd6d38b9800 nid=0x118f72000 runnable [118f71000]
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
    - locked <7f42b01c8> (a java.io.InputStreamReader)
    at java.io.InputStreamReader.read(InputStreamReader.java:167)
    at java.io.BufferedReader.fill(BufferedReader.java:136)
    at java.io.BufferedReader.readLine(BufferedReader.java:299)
    - locked <7f42b01c8> (a java.io.InputStreamReader)
    at java.io.BufferedReader.readLine(BufferedReader.java:362)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner$ReaderThread.run(RemoteTestRunner.java:140)

"Low Memory Detector" daemon prio=5 tid=7fd6cd800000 nid=0x118d22000 runnable [00000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" daemon prio=9 tid=7fd6d085f000 nid=0x118c1f000 waiting on condition [00000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" daemon prio=9 tid=7fd6d085e000 nid=0x118b1c000 waiting on condition [00000000]
   java.lang.Thread.State: RUNNABLE

"org.jacoco.agent.rt_3vqbej.controller.TcpClientController" daemon prio=5 tid=7fd6d085d800 nid=0x118a19000 runnable [118a18000]
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.net.SocketInputStream.read(SocketInputStream.java:182)
    at java.io.DataInputStream.readByte(DataInputStream.java:248)
    at org.jacoco.agent.rt_3vqbej.core.data.ExecutionDataReader.read(ExecutionDataReader.java:80)
    at org.jacoco.agent.rt_3vqbej.controller.TcpConnection.run(TcpConnection.java:59)
    at org.jacoco.agent.rt_3vqbej.controller.TcpClientController$1.run(TcpClientController.java:55)
    at java.lang.Thread.run(Thread.java:680)

"Signal Dispatcher" daemon prio=9 tid=7fd6ce81a000 nid=0x118768000 waiting on condition [00000000]
   java.lang.Thread.State: RUNNABLE

"Surrogate Locker Thread (Concurrent GC)" daemon prio=5 tid=7fd6ce819000 nid=0x118665000 waiting on condition [00000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=7fd6d200c000 nid=0x1183d7000 in Object.wait() [1183d6000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <7f42b6170> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
    - locked <7f42b6170> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=7fd6d200b000 nid=0x1182d4000 in Object.wait() [1182d3000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <7f42b6010> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:485)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
    - locked <7f42b6010> (a java.lang.ref.Reference$Lock)

"main" prio=5 tid=7fd6ce802000 nid=0x11046c000 runnable [11046a000]
   java.lang.Thread.State: RUNNABLE
    at sun.tools.attach.MacosxVirtualMachine.read(Native Method)
    at sun.tools.attach.MacosxVirtualMachine$SocketInputStream.read(MacosxVirtualMachine.java:235)
    - locked <7f30abf18> (a sun.tools.attach.MacosxVirtualMachine$SocketInputStream)
    at sun.tools.attach.HotSpotVirtualMachine.readInt(HotSpotVirtualMachine.java:214)
    at sun.tools.attach.MacosxVirtualMachine.execute(MacosxVirtualMachine.java:175)
    at sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:40)
    at sun.tools.attach.HotSpotVirtualMachine.loadAgentLibrary(HotSpotVirtualMachine.java:61)
    at sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:85)
    at mockit.internal.startup.JDK6AgentLoader.loadAgentAndDetachFromThisVM(JDK6AgentLoader.java:117)
    at mockit.internal.startup.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:61)
    at mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:21)
    at mockit.internal.startup.Startup.initializeIfNeeded(Startup.java:98)
    at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:112)
    at org.junit.runner.Runner.<clinit>(Runner.java:22)
    at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

"VM Thread" prio=9 tid=7fd6d2008800 nid=0x1181d1000 runnable 

"Gang worker#0 (Parallel GC Threads)" prio=9 tid=7fd6cb801000 nid=0x113896000 runnable 

"Gang worker#1 (Parallel GC Threads)" prio=9 tid=7fd6cb801800 nid=0x113999000 runnable 

"Gang worker#2 (Parallel GC Threads)" prio=9 tid=7fd6cb802000 nid=0x113a9c000 runnable 

"Gang worker#3 (Parallel GC Threads)" prio=9 tid=7fd6cb803000 nid=0x113b9f000 runnable 

"Gang worker#4 (Parallel GC Threads)" prio=9 tid=7fd6cb803800 nid=0x113ca2000 runnable 

"Gang worker#5 (Parallel GC Threads)" prio=9 tid=7fd6d1000000 nid=0x113da5000 runnable 

"Gang worker#6 (Parallel GC Threads)" prio=9 tid=7fd6d1001000 nid=0x113ea8000 runnable 

"Gang worker#7 (Parallel GC Threads)" prio=9 tid=7fd6d1001800 nid=0x113fab000 runnable 

"Concurrent Mark-Sweep GC Thread" prio=9 tid=7fd6d2000000 nid=0x117e77000 runnable 
"Gang worker#0 (Parallel CMS Threads)" prio=9 tid=7fd6d10dd800 nid=0x117471000 runnable 

"Gang worker#1 (Parallel CMS Threads)" prio=9 tid=7fd6d10de000 nid=0x117574000 runnable 

"VM Periodic Task Thread" prio=10 tid=7fd6d0868800 nid=0x118e25000 waiting on condition 

"Exception Catcher Thread" prio=10 tid=7fd6ce802800 nid=0x1106be000 runnable 
JNI global references: 1716

Heap
 par new generation   total 19136K, used 14513K [7f3000000, 7f44c0000, 7f44c0000)
  eden space 17024K,  81% used [7f3000000, 7f3d8a358, 7f40a0000)
  from space 2112K,  30% used [7f42b0000, 7f4352230, 7f44c0000)
  to   space 2112K,   0% used [7f40a0000, 7f40a0000, 7f42b0000)
 concurrent mark-sweep generation total 63872K, used 0K [7f44c0000, 7f8320000, 7fae00000)
 concurrent-mark-sweep perm gen total 21248K, used 8159K [7fae00000, 7fc2c0000, 800000000)
marchof commented 12 years ago

Aha, seems like this is a deadlock in combination with JMockit.

scooper4711 commented 12 years ago

Not sure I agree, but I could be wrong. The only two threads in waiting state are the Finalizer and the Reference Handler. Also, this exact test works just fine in Lion. The issue seems to be when I went to Mountain Lion. Deadlocks tend to (but not necessarily) be OS version independent. It happens with both Eclipse Indigo and Juno on Mountain Lion, but works fine in both Indigo and Juno on Lion. Of course, it's two different machines for the two different OSes, so it could be machine dependent.

Let me know if you need additional information to hunt this one down.

marchof commented 12 years ago

AFAIK if threads deadlock on a static class initializers they show up as RUNNABLE.

scooper4711 commented 12 years ago

Interesting. I did not know that. Will you be able to fix this? I get great value from using both EclEmma and jMockit.

marchof commented 11 years ago

Closing this issue here as it is an JaCoCo problem.

yerinu commented 11 years ago

Is there a jacoco issue url that keeps tracking of this issue?

marchof commented 11 years ago

Problems with JMockit are reported at jacoco/jacoco#35