The JConcurrency Tracer allows you to find deadlocks in your Java application.
The JConcurrency Tracer instruments a Java application to find potential deadlocks in the system. Jctrace will create a database of all taken and release locks in the application. In a second step jctrace will calculate if any two locks have any threads, where the lock order is inverse, which will flag a potential deadlock.
Note: Not every flagged potential deadlock, will be a real deadlock in your system. E.g. if you can guarantee that the found lock orders can not happen at the same time, the potential deadlock can not happen. But it would be no good concurrency design to rely on these fragile terms.
Jctrace will instrument and measure the following items:
synchronized
keyword- For any
Object
orClass
instance
- For any
synchronized
methodsjava.util.concurrent.locks.ReentrantLock
java.util.concurrent.locks.ReentrantReadWriteLock
java.util.concurrent.locks.StampedLock
The jctrace is currently only tested with Java 8 and Java 11.
Jctrace could also create stack traces of found potential deadlocks to ease the fix of the underlying problem.
To build the project just run:
gradlew shadowJar
The built jar file it then located in `subprojects/jctrace-core/build/libs/jctrace-core-1.0.0-SNAPSHOT-all.jar
First you have to create a measurement of your running application.
Start your application with the following additional Java-VM arguments:
-javaagent:jctrace-core-1.0.0-SNAPSHOT-all.jar
-Xbootclasspath/a:jctrace-core-1.0.0-SNAPSHOT-all.jar
-Dde.turban.DeadLockTracer.blacklist=org.eclipse;com.google
-Dde.turban.DeadLockTracer.stacktracingClasses=<ClassName>;<SecondClassName>
You could blacklist whole packages including all sub packages with -Dde.turban.DeadLockTracer.blacklist=
.
Packages are separated with an ;
.
You could enable the collection of stack traces for certain classes with -Dde.turban.DeadLockTracer.stacktracingClasses
Class names are separated with an ;
.
Full Path sample:
-javaagent:/Path/To/Jar/File/jctrace-core-1.0.0-SNAPSHOT-all.jar
-Xbootclasspath/a:/Path/To/Jar/File/jctrace-core-1.0.0-SNAPSHOT-all.jar
-Dde.turban.DeadLockTracer.blacklist=org.eclipse;com.google;org.apache;java;sun;org.osgi;com.sun;org.codehaus.groovy;groovy
-Dde.turban.DeadLockTracer.stacktracingClasses=pkg.to.class.ClassNameA;pkg.to.other.class.ClassB
-Djava.util.logging.config.file=/Your/path/to/logging.properties
You could open the UI with:
gradlew run -PdbFile=Deadlock.db
Note: In the current version the UI will the show anything, if there is no potential deadlock.
Or you could create an XML report from the Database, if you call:
gradlew runReportXml -PdbFile=Deadlock.db -PreportFile=DeadlockReport.xml
- Improve the usability of the UI
- Make the Load/Close buttons work correctly
- Display text, if not potential deadlock was found
- Improve the usability of measurement creation with a wrapper which calls the java application
- Add instrumentation for volatile field reads and writes to detect data races
- Add instrumentation for Atomic* classes reads and writes to detect data races
- Creator:
- Andreas Turban (GitHub: AndreasTu)