Bug 58436 - Data Race in class org/apache/juli/ClassLoaderLogManager
Data Race in class org/apache/juli/ClassLoaderLogManager
Status: RESOLVED FIXED
Product: Tomcat 8
Classification: Unclassified
Component: Util
8.0.26
PC All
: P2 minor (vote)
: ----
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2015-09-21 10:03 UTC by Thomas Krieger
Modified: 2015-09-21 13:01 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Krieger 2015-09-21 10:03:46 UTC
Using http://vmlens.com to find data races I found the following data race:
In ClassLoaderLogManager the method addLogger access the classLoaderLoggers hashmap synchronized but the method shutdown does not use any synchronization.

Here are example stacktraces:
localhost-startStop-1 (16)
java/util/concurrent/ThreadPoolExecutor$Worker.run 
java/util/concurrent/ThreadPoolExecutor.runWorker 
java/util/concurrent/FutureTask.run 
java/util/concurrent/Executors$RunnableAdapter.call
org/apache/catalina/startup/HostConfig$DeployWar.run
org/apache/catalina/startup/HostConfig.deployWAR
org/apache/catalina/core/StandardHost.addChild
org/apache/catalina/core/ContainerBase.addChild
org/apache/catalina/core/ContainerBase.addChildInternal
org/apache/catalina/util/LifecycleBase.start
org/apache/catalina/core/StandardContext.startInternal
org/apache/catalina/core/ContainerBase.getLogger
org/apache/juli/logging/LogFactory.getLog
org/apache/juli/logging/LogFactory.getInstance
org/apache/juli/logging/DirectJDKLog.getInstance
org/apache/juli/logging/DirectJDKLog.<init>
java/util/logging/Logger.getLogger
java/util/logging/Logger.demandLogger
java/util/logging/LogManager.demandLogger
org/apache/juli/ClassLoaderLogManager.getLogger
org/apache/juli/ClassLoaderLogManager.getClassLoaderInfo
org/apache/juli/ClassLoaderLogManager$2.run
org/apache/juli/ClassLoaderLogManager$2.run
org/apache/juli/ClassLoaderLogManager.readConfiguration
java/util/WeakHashMap.put 

Thread-1 (12)
java/util/concurrent/ThreadPoolExecutor$Worker.run	
org/apache/juli/ClassLoaderLogManager$Cleaner.run	
org/apache/juli/ClassLoaderLogManager.shutdown	
java/util/WeakHashMap$HashIterator.nextEntry
Comment 1 Mark Thomas 2015-09-21 13:01:22 UTC
Thanks for the report. Fixed in trunk, 8.0.x (for 8.0.27 onwards) and 7.0.x (for 7.0.65 onwards).