Bug 58367 - Data race on field org.apache.tomcat.util.http.HttpMessages.st_200
Data race on field org.apache.tomcat.util.http.HttpMessages.st_200
Status: RESOLVED FIXED
Product: Tomcat 8
Classification: Unclassified
Component: Util
8.0.x-trunk
PC Linux
: P2 normal (vote)
: ----
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2015-09-12 00:58 UTC by Yilong Li
Modified: 2015-09-13 20:39 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yilong Li 2015-09-12 00:58:30 UTC
Reported by RV-Predict (a dynamic race detector) when running the test suite:
Data race on field org.apache.tomcat.util.http.HttpMessages.st_200: {{{
    Concurrent write in thread T29 (locks held: {Monitor@3fece8b3})
 ---->  at org.apache.tomcat.util.http.HttpMessages.getMessage(HttpMessages.java:73)
        at org.apache.coyote.http11.AbstractOutputBuffer.<init>(AbstractOutputBuffer.java:134)
        at org.apache.coyote.http11.Http11Processor.<init>(Http11Processor.java:60)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.createProcessor(Http11Protocol.java:171)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:277)
        - locked Monitor@3fece8b3 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:259) 
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    T29 is created by T15
        at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:1010)

    Concurrent read in thread T27 (locks held: {Monitor@3bb9edae})
 ---->  at org.apache.tomcat.util.http.HttpMessages.getMessage(HttpMessages.java:75)
        at org.apache.coyote.http11.AbstractOutputBuffer.<init>(AbstractOutputBuffer.java:134)
        at org.apache.coyote.http11.Http11Processor.<init>(Http11Processor.java:60)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.createProcessor(Http11Protocol.java:171)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:277)
        - locked Monitor@3bb9edae at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:259) 
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    T27 is created by T15
        at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:1010)
}}}

The implementation of lazy initialization of this field is non-thread-safe.
Comment 1 Mark Thomas 2015-09-13 11:58:33 UTC
Note: This code has been removed entirely for trunk.

For 8.0.x and earlier this isn't an issue but it is probably worth reviewing to see if there is a cleaner/simpler (and thread-safe) solution we can use.
Comment 2 Mark Thomas 2015-09-13 20:39:26 UTC
Fixed the rare/unlikely data race in 8.0.x for 8.0.27 onwards.