Open mkit opened 7 years ago
Thanks Michal.
I can't reproduce this anymore after upgrading to 0.7.9 but I'll keep trying, as it is tricky to reproduce. As this code doesn't seem to have changed lately I suspect the race is still there but something has changed timing-wise to make it show up less.
When starting our application we see those warnings about duplicate class entries:
[quasar] WARNING: Duplicate class entries with different data for class: [ClassName]
This warning is printed in therecordSuspendableMethods
method, line 262. After debugging the instrumentation process and putting a breakpoint at that line we see the following stack traces:From the code above you see, that you get this warning only if the
ClassEntry
instance already exists in theclasses
map and if it is different (considering references) than the new one.The stack trace above indicates that the
ClassEntry
instance is not present for theclassName
in theclasses
map at the time of theif (entry == null)
condition evaluation at line 319.The above snippet is to confirm this further.
Therefore, there is a race condition in the
classes
map access by different threads. Depending on the intended behaviour there could be (at least) 3 solutions that we would like to suggest:1) In the first snippet you see that both the
oldEntry
and theentry
are the same in terms of data and thus can be possibly compared based on theequal
method basis, instead of==
reference comparison.2) extend the
synchronized
block in thecheckClass
method. This would possibly affect performance.3) reduce the log level to DEBUG or even TRACE (if combined with solution 1)).