Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

possible data race on the non-thread-safe NGServer.allNailStats #62

Closed
yilongli opened this issue Aug 7, 2015 · 1 comment
Closed

Comments

@yilongli
Copy link

yilongli commented Aug 7, 2015

Hi, I am a developer of the K framework. While we are trying to catch the data races inside the K framework with a dynamic race detector, the race detector also prints out some race reports inside Nailgun, which K uses heavily.

Here is one:

Data race on field java.util.HashMap.$state: {{{
    Concurrent write in thread T15 (locks held: {Monitor@444ecc49})
 ---->  at com.martiansoftware.nailgun.NGServer.getOrCreateStatsFor(NGServer.java:245)
        - locked Monitor@444ecc49 at com.martiansoftware.nailgun.NGServer.getOrCreateStatsFor(NGServer.java:241) 
        at com.martiansoftware.nailgun.NGServer.nailStarted(NGServer.java:258)
        at com.martiansoftware.nailgun.NGSession.run(NGSession.java:314)
    T15 is created by T13
        at com.martiansoftware.nailgun.NGSessionPool.take(NGSessionPool.java:85)

    Concurrent read in thread T14 (locks held: {})
 ---->  at com.martiansoftware.nailgun.NGServer.nailFinished(NGServer.java:269)
        at com.martiansoftware.nailgun.NGSession.run(NGSession.java:332)
    T14 is created by T13
        at com.martiansoftware.nailgun.NGSessionPool.take(NGSessionPool.java:85)
}}}

It's basically saying that there are concurrent and conflicting accesses to NGServer.allNailStats, which is a HashMap, and that the allNailStats.get() operation is not properly synchronized. It seems the allNailStats.get() should also be wrapped inside a synchronization block.

Can you please confirm whether it is a false positive of the race detector? Thanks!

@sbalabanov-zz
Copy link
Contributor

Closing all issues older than 6 months; please reopen if it is still relevant

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants