Bug 58388

Summary: Data race on field org.apache.coyote.RequestInfo.stage
Product: Tomcat 8 Reporter: Yilong Li <yilong.li>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 8.0.x-trunk   
Target Milestone: ----   
Hardware: PC   
OS: Linux   

Description Yilong Li 2015-09-12 16:32:42 UTC
Reported by RV-Predict (a dynamic race detector) when running the test suite:
Data race on field org.apache.coyote.RequestInfo.stage: {{{
    Concurrent read in thread T21 (locks held: {})
 ---->  at org.apache.coyote.RequestInfo.getStage(RequestInfo.java:172)
        at org.apache.coyote.http11.Http11Nio2Processor.actionInternal(Http11Nio2Processor.java:520)
        at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:924)
        at org.apache.coyote.Request.action(Request.java:380)
        at org.apache.catalina.connector.Request.cometClose(Request.java:2583)
        at org.apache.catalina.connector.CometEventImpl.close(CometEventImpl.java:98)
        at org.apache.catalina.comet.TestCometProcessor$AsyncCometCloseThread.run(TestCometProcessor.java:665)
    T21 is created by T20
        at org.apache.catalina.comet.TestCometProcessor$AsyncCometCloseValve.invoke(TestCometProcessor.java:648)

    Concurrent write in thread T20 (locks held: {Monitor@78eabf38})
 ---->  at org.apache.coyote.RequestInfo.setStage(RequestInfo.java:176)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1129)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
        at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.doRun(Nio2Endpoint.java:1074)
        at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.run(Nio2Endpoint.java:1033)
        - locked Monitor@78eabf38 at org.apache.tomcat.util.net.Nio2Endpoint$SocketProcessor.run(Nio2Endpoint.java:1032)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    T20 is created by T19
        at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:1010)
}}}
Comment 1 Yilong Li 2015-09-13 21:37:08 UTC
I don't know enough about the code here but shouldn't such "state" variable be declared as volatile or atomic to avoid memory visibility issues when altering state?
Comment 2 Mark Thomas 2015-09-17 08:20:33 UTC
Fixed in 8.0.x for 8.0.27 onwards.